2013-11-28 98 views
2

我有一個ASP.NET MVC3 Razor項目。我想添加aspx頁面到這個項目,我發現它可以通過使用MapPageRoute。我將它添加到我的GlobalAsax.RegisterRoutes中,它將我重定向到我的aspx頁面。但也最老的頁面也被重定向到這一點 - 他們;再這樣讓網址:MapPageRoute重定向前頁面

http://localhost:61000/AEM/Report?action=EditUser&controller=Settings 

我的RegisterRoutes方法:

public static void RegisterRoutes(RouteCollection routes) 
    { 
     routes.MapPageRoute(
      "TelerikReport", 
      "AEM/Report", 
      "~/WebForms/TelerikReport.aspx", true 
     ); 

     routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

     routes.MapRoute(
       "Default", // Route name 
       "{controller}/{action}/{id}", // URL with parameters 
       new { controller = "Account", action = "LogOn", id = UrlParameter.Optional } // Parameter defaults 
    } 

我在做什麼錯在這裏?

編輯: 我注意到,當我在我的控制器中使用「return RedirectToAction(...)」時,它重定向頁面錯誤。

+0

你是什麼意思的大部分舊網頁?不是全部,對嗎?還有一件事你有任何控制器「AEM」和方法「報告」? –

+0

是的,不是全部。我有「AEM」控制器,沒有「報告」方法。我剛剛將routeURL更改爲「AEM2/Report」,問題仍然存在。例如,在應用程序啓動時,它將我重定向到:http:// localhost:61000/AEM2/Report?action = Index&controller = Home,它應該是http:// localhost:61000/Home/Index –

回答

1

嘗試修改你的代碼,如:

routes.MapPageRoute(
     "TelerikReport", 
     "AEM/Report/{*queryvalues}", 
     "~/WebForms/TelerikReport.aspx", true 
    ); 

雖然我不知道,但你可以試試看。如解釋Here

+0

There仍然是這個問題。我注意到當我使用RedirectToAction時發生了這種情況。我在應用程序開始時或用戶想要訪問某些操作而不登錄時使用它。此外,僅在登錄後,我現在就無法使用我的應用程序。 –

+0

如果您想在登錄前使用它,請將最後一個參數作爲false傳遞。即'routes.MapPageRoute( 「TelerikReport」, 「AEM/Report/{* queryvalues}」, 「〜/ WebForms/TelerikReport.aspx」,false ); –

+1

不,它仍然不工作:/ –