最近、mvc3 のローカリゼーション構造を lang as subdomain (fr.domain.com) から lang as path (domain.com/fr) に切り替えました。
アカウントログオンへの自動リダイレクト以外はすべて正常に機能します。
認証されていない状態で domain.com/fr/test にアクセスしようとすると、domain.com/Account/LogOn?ReturnUrl にリダイレクトされます...
/fr/Account/LogOn?ReturnUrl... にリダイレクトされるようにサイトを構成するにはどうすればよいですか?
編集 :
ルート マッピングを使用します
routes.MapRoute(
"DefaultLocalized", // Route name
"{lang}/{controller}/{action}/{id}", // URL with parameters
new { lang = "en", controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
, new { lang = "fr" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
SOLUTION : これは、developer10214 の提案に基づく私のソリューションの実装です。
public ActionResult LogOn()
{
if (System.Web.HttpContext.Current.Request.Url.Query.Contains("%2ffr%2f") && System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName != "fr")
return Redirect("/fr/Account/LogOn" + System.Web.HttpContext.Current.Request.Url.Query);
LogOnModel model = new LogOnModel() { UserName = "", Password = "" };
return View(model);
}