基于我在stackoverflow中看到的内容,我有一个Html.BeginForm
:
@using (Html.BeginForm("Index", "Account", new {returnUrl = ViewBag.ReturnUrl}, FormMethod.Post))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new {@class = "text-danger"})
@Html.LabelFor(model => model.Username, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.Username)
@Html.ValidationMessageFor(model => model.Username, "", new {@class = "text-danger"})
<br/>
@Html.LabelFor(model => model.Password, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.PasswordFor(model => model.Password)
@Html.ValidationMessageFor(model => model.Password, "", new {@class = "text-danger"})
<br/>
<input type="submit" value="Log in" />
}
在调试模式下,我在Controller中的returnUrl上得到一个空值,但模型已填满。
这是我的Web.config
<system.web>
<globalization culture="en-GB" uiCulture="en-GB"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Index" defaultUrl="~/Home/Default" timeout="20" slidingExpiration="true" />
</authentication>
<roleManager enabled="true" defaultProvider="MyProvider">
<providers>
<clear/>
<add name="MyProvider" type="EventCalendar.MyRoleProvider.SiteRole"/>
</providers>
</roleManager>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
我做错了什么?感谢。