2012-01-28 10 views
0

私は、彼らがログインしていないとき、私のウェブサイトにユーザーをリダイレクト場所を変更したいと思います。フォーム認証のloginurlを変更するにはどうすればよいですか?

<authentication mode="Forms"> 
    <forms loginUrl="~/Account/LogOn" timeout="30" /> 
</authentication> 

それは、デフォルトのコントローラのフォルダ内のアクションメソッドログオンおよびこれに添付ビューをAccountControllerを使用しています。

私はこのフォルダに別のAccountControllerを置いています:Areas/SmallSurvey/Controllers/Account アクションメソッドの名前は同じです。私は使用する構文を理解することはできません。

私は別の名前を試しましたが、どれも動作しませんでした。どのように私はそれを変更するのですか?これはSmallSurveyAreaRegistration.csがどのように見えるかさ

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 
       new[] { "MvcApplication3.Controllers" } 
      ); 
     } 

Global.asax.cs

public override void RegisterArea(AreaRegistrationContext context) 
     { 
      context.MapRoute(
       "SmallSurvey_default", 
       "SmallSurvey/{controller}/{action}/{id}", 
       new { action = "Index", id = UrlParameter.Optional } 
      ); 

      context.MapRoute("Login", "SmallSurvey/Account/LogOn", 
       new { controller = "Account", action = "LogOn" }, 
       new[] { "MvcApplication3.Areas.SmallSurvey.Controllers" }); 
     } 

"SmallSurvey /アカウント/ログオンを" アクセスしようとするとき、私は次のエラーを取得します:

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /SmallSurvey/Account/LogOn 

答えて

1
<authentication mode="Forms"> 
    <forms loginUrl="~/SmallSurvey/Account/LogOn" timeout="30" /> 
</authentication> 
+0

それは動作しません。私はルートに何かを設定する必要がありますか? – Kenci

+0

@Kenci、「うまくいかない」というのは、非常に正確な問題記述ではない。もう少し具体的にできますか? –

+0

これはエラーです。 説明:HTTP 404。探しているリソース(またはその依存関係の1つ)が削除されているか、名前が変更されているか、一時的に利用できない可能性があります。次のURLを確認し、正しく入力されていることを確認してください。 リクエストされたURL:/ SmallSurvey/Account/LogOn – Kenci

2
Try this ~/SmallSurvey/Account/logon 

[編集]それは仕事をdoesntの

context.MapRoute(

     "SmallSurvey_default", 
     "SmallSurvey/{controller}/{action}/{id}", 
     new { action = "Index", id = UrlParameter.Optional }, 
.... 
     ); 
+0

ルートでエリア名 registration..noticeお住まいの地域でのルートである必要があり、次の..あなたの応答に基づきます。私はルートに何かを設定する必要がありますか? – Kenci

関連する問題