2012-01-28 26 views
0

我想改變的時候還沒有登錄他們自己的網站重定向用戶的地方。如何更改表單身份驗證loginurl?

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

它使用的AccountController默認Controllers文件夾,操作方法登錄和查看連接到這一點。

我有另一個AccountController放置在這個文件夾:Areas/SmallSurvey/Controllers/Account action方法的名字是一樣的。我無法弄清楚使用的語法。

我嘗試過不同的名字,但都沒有工作。我如何改變它?

的Global.asax.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" } 
      ); 
     } 

這是SmallSurveyAreaRegistration.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 2012-01-28 21:14:11

+0

@Kenci,「不起作用」不是一個非常精確的問題描述。你能更具體一點嗎? – 2012-01-28 21:15:41

+0

這是錯誤: 說明:HTTP 404.您正在查找的資源(或其某個依賴項)可能已被刪除,名稱已更改或暫時不可用。請檢查以下網址並確保它拼寫正確。 請求的網址:/ SmallSurvey /帳戶/登錄 – Kenci 2012-01-28 21:22:54

2
Try this ~/SmallSurvey/Account/logon 

[編輯根據您迴應] ..以下應該在您所在地區的路線registration..notice的區域名稱

context.MapRoute(

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

它不工作的路線。我是否需要在路線中設置某些東西? – Kenci 2012-01-28 21:15:03

相關問題