0
我正在創建asp.net mvc登錄頁面。這很簡單。與其他人一樣。控制器包含2個方法。asp.net mvc簡單問題
我的問題是
我調試首先LogOn
方法。 ReturnUrl
有價值。例如"Admin/Index"
。調試完第二個LogOn
方法後。但是ReturnUrl
是空的。
public ActionResult LogOn(string ReturnUrl) // First method
{
return View();
}
[HttpPost]
public ActionResult LogOn(string eUserName, string ePassword, Boolean rememberMe, string ReturnUrl) //Second Method
{
...
}
我的看法是這裏>>
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Login</title>
</head>
<body>
<table style="width: 100%">
<tr>
<td align="center">
<div style="width: 800px;">
<%=Html.ValidationSummary() %>
</div>
</td>
</tr>
<tr>
<td align="center">
<% Html.RenderPartial("LoginControl"); %>
</td>
</tr>
</table>
</body>
</html>
Logincontrol
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<div style="text-align: left; width:150px;margin-top:20px;">
<% using (Html.BeginForm("Logon", "Account", FormMethod.Post))
{ %>
<div>
Хэрэглэгчийн нэр:</div>
<div>
<%= Html.TextBox("eUserName") %>
</div>
<div style="margin-top:5px;">
Нууц үг:</div>
<div >
<%= Html.Password("ePassword") %>
</div>
<div style="margin-top:5px;">
<%= Html.CheckBox("rememberMe") %>
<label class="inline" for="rememberMe">
Намайг сана?</label>
</div>
<div style="text-align:center;margin-top:5px;">
<input type="submit" value="Нэвтрэх" />
</div>
<%} %>
</div>
爲什麼RETURNURL返回null?
發生了什麼?
編輯
感謝蒂姆·羅伯茨
最後正確的代碼是在這裏>>
<% using (Html.BeginForm("Logon", "Account",new { ReturnUrl = HttpContext.Current.Request.QueryString["returnUrl"]} FormMethod.Post)){ %>