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

asp.net 4.0 網絡表單路由 - 默認/通配符路由

asp.net 4.0 web forms routing - default/wildcard route(asp.net 4.0 網絡表單路由 - 默認/通配符路由)
本文介紹了asp.net 4.0 網絡表單路由 - 默認/通配符路由的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

當使用帶有 Web 窗體的 ASP.NET 4.0 路由來生成將充當某種通配符的路由時,我有一種簡單的方法嗎?

I there a simple way when using ASP.NET 4.0 routing with Web Forms to produce a route that will act as some kind of wildcard?

在我看來,在 WebForms 中,您必須為每個頁面指定一個路由 - 我正在尋找某種通用路由,可以在不需要任何特定內容的情況下使用,也許直接從路徑映射到路徑,所以...

It seems to me that within WebForms, you have to specify a route for every page - I am looking for some kind of generic route that can be used where nothing specific is required, perhaps mapping directly from path to path so...

http://somedomain.com/folder1/folder2/page 可能會映射到文件夾1/folder2/page.aspx

http://somedomain.com/folder1/folder2/page would possibly map to folder1/folder2/page.aspx

有什么建議嗎?

謝謝

推薦答案

你可以像這樣匹配所有剩余的路由:

You can match all remaining routes like this:

routes.MapPageRoute("defaultRoute", "{*value}", "~/Missing.aspx");

在這種情況下,我們知道所有路由,并希望將其他任何內容發送到丟失"/404 頁面.請務必將此作為 last 路由,因為它是一個通配符,可以捕獲所有內容.

In this case, we know all routes, and want to send anything else to a "missing"/404 page. Just be sure to put this as the last route, since it is a wildcard and will catch everything.

您也可以用同樣的方式注冊一個路由,但在內部會映射到一個頁面,如下所示:

Alternatively you could register a route the same way, but internally does mapping to a page, like this:

routes.Add(new Route("{*value}", new DefaultRouteHandler()));

該處理程序類將執行您的通配符映射,如下所示:

That handler class would do your wildcard mapping, something like this:

public class DefaultRouteHandler : IRouteHandler
{
  public IHttpHandler GetHttpHandler(RequestContext requestContext)
  { 
    //Url mapping however you want here:
    var pageUrl = requestContext.RouteData.Route.Url + ".aspx";

    var page = BuildManager.CreateInstanceFromVirtualPath(pageUrl, typeof(Page)) 
               as IHttpHandler;
    if (page != null)
    {
      //Set the <form>'s postback url to the route
      var webForm = page as Page;
      if (webForm != null) 
         webForm.Load += delegate { webForm.Form.Action = 
                                    requestContext.HttpContext.Request.RawUrl; };
    }
    return page;
  }
}

這在奇怪的地方被打破了一點,以防止水平滾動,但你明白了整體觀點.再次確保這是最后一個路線,否則它將處理您的所有路線.

This is broken a bit in odd places to prevent horizontal scrolling, but you get the overall point. Again, make sure this is the last route, otherwise it'll handle all your routes.

這篇關于asp.net 4.0 網絡表單路由 - 默認/通配符路由的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
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屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 99视频免费在线观看 | 在线观看视频福利 | 欧美男人天堂 | 麻豆av在线免费观看 | 久久久激情 | 秋霞在线一区 | 免费在线观看av网址 | 亚洲视频一区在线播放 | 日韩视频精品在线 | av黄色在线| 精品欧美乱码久久久久久 | 欧美在线a | 操操日| 国产目拍亚洲精品99久久精品 | 免费在线观看一区二区 | 久久91| 在线观看免费av网 | 九九综合九九 | 日韩在线观看一区二区三区 | 亚洲欧美精| 特级生活片 | 国产精品视频一区二区三区 | 91久久久久久久 | 欧美日韩国产一区二区三区 | 亚洲国产成人精品一区二区 | 久久久久国产精品 | 免费观看成人鲁鲁鲁鲁鲁视频 | 国产精品1区 | av一二三四 | 精品无码久久久久国产 | 午夜爽爽男女免费观看hd | 久久精品亚洲欧美日韩久久 | 日韩在线不卡 | 一区二区免费 | 国产精品成人一区二区三区 | 九九色综合 | 久久综合一区二区三区 | 一级在线视频 | 免费国产视频 | 欧美日本韩国一区二区 | 蜜臀网 |