久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

將 MapPageRoute 添加到 asp.net mvc 項目后,站點停止

After add MapPageRoute to an asp.net mvc project, the site stops to enter in Home Controller(將 MapPageRoute 添加到 asp.net mvc 項目后,站點停止進入 Home Controller)
本文介紹了將 MapPageRoute 添加到 asp.net mvc 項目后,站點停止進入 Home Controller的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在嘗試在我的 asp.net mvc 項目中路由一個 .aspx(webforms 頁面).我在 global.asax 中注冊頁面:

I'm trying to route a .aspx (webforms page) in my asp.net mvc project. I register the page in global.asax:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapPageRoute("Tickets", "Reports/Tickets", "~/WebForms/Reports/Tickets.aspx");
routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });

問題是,在我添加第二行之后,站點停止進入我的主控制器(索引操作)并重定向到:http://localhost:37538/Reports/Tickets?action=Index&controller=Login%22 總是我運行項目.

The problem is, after i add the second line, the site stops to enter in my Home Controller (Index Action) and is redirecting to: http://localhost:37538/Reports/Tickets?action=Index&controller=Login%22 always that i run the project.

項目詳情:

  • Asp.Net MVC 3
  • 表單驗證
  • .Net 4.0

Obs:要重現此錯誤,請在 /WebForms/Reports 文件夾中創建 Tickets webforms 頁面后,創建一個新的 asp.net mvc 項目作為 Internet 應用程序,并注冊新路線.運行項目(可能您已登錄),現在注銷,您將被重定向到 http://localhost:35874/Reports/Tickets?action=LogOff&controller=Account,為什么?

Obs: to reproduce this error, create a new asp.net mvc project as internet app, after create the Tickets webforms page inside a /WebForms/Reports folder, and register the new route. Run the project (probably you're logged), so now logoff and you will be redirected to http://localhost:35874/Reports/Tickets?action=LogOff&controller=Account, so why?

推薦答案

解決了! 所以,我們需要在 webforms 路由中添加一個路由約束,以確保它只捕獲傳入的路由,而不是傳出路由生成.

Solved! So, we need to add a route contraint to the webforms route to ensure that it only catches on incoming routes, not outgoing route generation.

將以下類添加到您的項目中(在新文件中或 global.asax.cs 的底部):

Add the following class to your project (either in a new file or the bottom of global.asax.cs):

public class MyCustomConstraint : IRouteConstraint{
    public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection){
        return routeDirection == RouteDirection.IncomingRequest;
    }
}

然后將Tickets路由更改為以下:

Then change the Tickets route to the following:

routes.MapPageRoute(
    "Tickets",
    "Reports/Tickets",
    "~/WebForms/Reports/Tickets.aspx",
    true, null, 
    new RouteValueDictionary { { "outgoing", new MyCustomConstraint() } }
);

這篇關于將 MapPageRoute 添加到 asp.net mvc 項目后,站點停止進入 Home Controller的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
Getting access token using email address and app password from oauth2/token(使用電子郵件地址和應用程序密碼從 oauth2/token 獲取訪問令牌)
New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 應用程序在通過管理門戶更新之前無法運行)
主站蜘蛛池模板: 影音先锋欧美资源 | 精品国产乱码久久久久久蜜臀 | 日韩精品国产精品 | 国产成人影院 | 91精品国产一区二区三区 | 亚洲一区二区三区免费观看 | 欧美最猛黑人 | 一区二区三区四区视频 | 免费激情网站 | 国产精品一区二区在线观看 | 国产日韩中文字幕 | 亚洲精选一区二区 | 国产色片在线 | 欧日韩不卡在线视频 | 久久精品一区二区三区四区 | 久久69精品久久久久久久电影好 | 欧美国产日韩一区 | 精品中文字幕在线观看 | 99精品视频在线观看免费播放 | 国内精品久久影院 | 亚洲一区 中文字幕 | 中文字幕爱爱视频 | 国产精品视频一二三区 | 天天干狠狠干 | 碰碰视频 | 91久操视频| 亚洲国产成人久久久 | 黄色国产在线视频 | 日韩视频在线一区 | 特黄毛片| av手机在线播放 | 欧美精品欧美精品系列 | 99日韩 | 国产精品久久久久久52avav | 欧美一区二区三区在线看 | 亚洲久久一区 | 亚洲一区二区在线 | 日韩在线91 | 我要看一级片 | 久久久久网站 | 精品一区国产 |