1. 私はホームページ(ホーム/インデックス)を持っています。ここで言語を選択します。 "localhost:xxxx/Account/Index?language=en-US".
RedirectToActionはURLを変更しません
3. データを入力する(:"localhost:xxxx".
2. 言語を選択したら、次は、ログインページ(アカウント/インデックス)ここで URLはこれですが、次のとおりです。 は、ここにURLはこれですユーザー名/パスワード)とログオン]ボタンをクリックし、[ユーザー/インデックスにリダイレクトが、URLはアカウント/ [ログオンに
マイフォームのまま:
<% using (Html.BeginForm("LogOn", "Account")) { %>
<div data-role="fieldcontain" class="ui-hide-label">
<label for="username">Username:</label>
<%: Html.TextBoxFor(m => m.Username, new { placeholder = "Username" })%>
</div>
<div data-role="fieldcontain" class="ui-hide-label">
<label for="password">Password:</label>
<%: Html.PasswordFor(m => m.Password, new { placeholder = "Password" })%>
</div>
<fieldset class="ui-grid-a">
<div class="ui-block-a"><button type="reset" data-theme="d">Reset</button></div>
<div class="ui-block-b"><button type="submit" data-theme="b">Log On</button></div>
</fieldset>
<% } %>
アカウント・コントローラ:
[HandleError]
public class AccountController : Controller
{
public ActionResult Index(string language = "es-Es")
{
return View();
}
[HttpPost]
public ActionResult LogOn(UserModel user)
{
FormsAuthentication.SetAuthCookie(user.Username, false);
return RedirectToAction("Index", "User");
}
public ActionResult LogOff()
{
return View();
}
}
のGlobal.asax:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
がどのようにURLを作成するには、次のとおりです。ローカルホスト:XXXX /ユーザー/インデックス?あなたのAccount/Index.cshtml
ビューで
data-ajax = "false"をフォームに追加するだけで、醜い修正を行わなくても動作します:) – gonace