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

asp.net 4.0 網(wǎng)絡(luò)表單路由 - 默認(rèn)/通配符路由

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

問題描述

限時送ChatGPT賬號..

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

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 中,您必須為每個頁面指定一個路由 - 我正在尋找某種通用路由,可以在不需要任何特定內(nèi)容的情況下使用,也許直接從路徑映射到路徑,所以...

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");

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

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.

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

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()));

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

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.

這篇關(guān)于asp.net 4.0 網(wǎng)絡(luò)表單路由 - 默認(rèn)/通配符路由的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

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 令牌授權(quán)不起作用)
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(如何獲取守護進程或服務(wù)器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發(fā)技
.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(異步調(diào)用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 欧美亚洲视频在线观看 | 亚洲精品久久久久久宅男 | 日日操夜夜干 | 一区在线播放 | 亚洲444kkkk在线观看最新 | 亚洲成av人片在线观看 | 农村黄性色生活片 | 日日干干夜夜 | 一区二区三区亚洲精品国 | 亚州国产 | 伦理片97| 成人av网站在线观看 | 天天插天天搞 | 日韩一 | 日韩av在线一区二区 | 日韩精品视频在线免费观看 | 中国一级特黄真人毛片免费观看 | 久久精品色欧美aⅴ一区二区 | 色婷婷久久综合 | 99久久精品免费看国产四区 | 国产中文字幕在线观看 | 99久久99久久精品国产片果冰 | 日韩av免费在线电影 | 亚洲精品视频观看 | 欧美一区二区免费 | 狠狠影院| 青青草这里只有精品 | 久久亚洲国产精品 | 欧美成人性生活 | 久久夜视频 | 国产精品久久久久久久久久三级 | 中文字幕一区二区三区不卡 | 国产精品久久久久久高潮 | 日韩一区中文字幕 | 日韩在线精品视频 | 国产精品69毛片高清亚洲 | 中文字幕精品一区二区三区精品 | 久久亚洲精品国产精品紫薇 | 亚洲国产成人av | 中文日韩字幕 | 毛片com |