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

ASP.NET - 構建自己的路由系統

ASP.NET - Building your own routing system(ASP.NET - 構建自己的路由系統)
本文介紹了ASP.NET - 構建自己的路由系統的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

在最近的一個項目中,我用 PHP 構建了自己的 MVC 框架.我實現的其中一件事是路由系統.我使用 Apache 的 mod_rewrite 將所有請求發送到 index.php,然后解析 URI 以提取信息并路由請求.

In a recent project, I built my own MVC framework in PHP. One of the things I implemented was a routing system. I used Apache's mod_rewrite to send all requests to index.php, and then parsed the URI to extract information and route the request.

我現在正在涉足 ASP.NET,我想知道是否/如何執行類似的操作.有沒有辦法將所有請求(類似于 WordPress 的方式)路由到執行中央路由處理的一個頁面?我知道 ASP.NET 的 MVC 框架,但我想自己嘗試一下,因為我正在修補和學習.

I'm dabbling in ASP.NET now, and I'm wondering if/how I might perform something similar. Is there a way to route all requests (similar to the way WordPress does it) to one page where central route processing is performed? I'm aware of the MVC framework for ASP.NET, but I'd like to take a stab at this myself as I'm tinkering around and learning.

順便說一句,我的托管服務提供商運行 IIS 6

BTW, my hosting provider runs IIS 6

推薦答案

這將是一個很長的答案,因為我想確保您完全了解可以完成您想做的事情的所有方法.

This is going to be a long answer, because I want to make sure you are fully aware of all the ways you can accomplish what you want to do.

支持 ASP.NET MVC 框架的路由引擎將與傳統的 ASP.NET 框架一起使用.您可以利用 RouteTable 并分配路由,就像在 ASP.NET MVC 應用程序中一樣.您只是沒有在傳統的 ASP.NET 站點中獲得 MVC 部分.這對 ASP.NET 框架來說是一個巨大的增強,很高興看到他們重用該代碼并使其在兩個框架中都工作.如果您想了解更多信息,請查看 ScottGu 的 post 并向下滾動到 URL 路由改進.這里還有一個 參考使用 Phil Haack 在 WebForms 中的 System.Web.Routing.

The routing engine that powers the ASP.NET MVC Framework will work with the traditional ASP.NET Framework. You can take advantage of using the RouteTable and assigning routes, just like you would in an ASP.NET MVC application. You just don't get the MVC portion in traditional ASP.NET sites. That was a huge enhancement for the ASP.NET Framework and it was great to see them reuse that code and make it work in both frameworks. If you want to learn more about this, check out ScottGu's post and scroll down to URL Routing Improvements. Also here is a reference on how to use the System.Web.Routing in WebForms by Phil Haack.

現在,如果您仍然想自己編寫.您將需要學習 ASP.NET HTTP 管道以及如何實現 IHttpModule 和 IHttpHandler接口來創建您自己的 HttpModule 或 HttpHandler 類來處理您的路由.這些接口是編寫自己的路由引擎的關鍵.為了幫助將這些接口放在一個工作示例中,我不推薦此 MSDN 文章 夠了.它向您展示了如何使用任一界面,并解釋了創建您自己的路由/url 重寫引擎時的差異.

Now, if you still want to write you own. You will need to learn the ASP.NET HTTP pipeline and how to implement the IHttpModule and the IHttpHandler interfaces to create your own HttpModule or HttpHandler class to handle your routing. These interfaces are the key in writing your own routing engine. To help put those interfaces in a working example, I couldn't recommend this MSDN article enough. It shows you how to with either interface and explains the differences when creating your own routing/url rewriting engine.

現在,如果您發現這對您來說可能太多了.您可以使用已經在 .NET 中編寫路由/url 重寫引擎的人使用第三方庫.這是我不久前看到的一個問題,詢問What Url rewriter你使用 ASP.Net 嗎?"就在這里.

Now, if you find out that this might be to much for you. There are third party libraries you can use of people who already wrote a routing/url rewriting engine in .NET. Here is a question that I saw not to long ago asking "What Url rewriter do you use for ASP.Net?" right here on SO.

這篇關于ASP.NET - 構建自己的路由系統的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 超時)
主站蜘蛛池模板: 久久亚洲天堂 | 国产精品av久久久久久毛片 | 不卡视频一区 | 亚洲国产精品一区二区三区 | 亚洲三级在线观看 | 91精品国产91久久久久青草 | 中文字幕国产日韩 | 久久精品国产一区二区电影 | 亚洲欧美日韩系列 | 亚洲永久字幕 | 一区二区三区欧美在线 | 国产一区二区观看 | 99re在线视频| h视频免费看 | 亚洲一区二区在线电影 | 成人国产一区二区三区精品麻豆 | 国产欧美视频一区二区 | 亚洲乱码国产乱码精品精98午夜 | www精品| 亚洲一区精品视频 | 一级做受毛片免费大片 | 国产激情在线 | 不卡视频一区二区三区 | 91偷拍精品一区二区三区 | 亚洲精品免费在线 | 91久久精品一区二区二区 | 91精品国产欧美一区二区成人 | 欧美日韩在线观看一区 | 日韩欧美精品在线播放 | 亚欧洲精品在线视频免费观看 | 色综久久 | 黄色一级免费看 | 老司机久久 | 亚洲天堂二区 | 成人午夜网站 | 狠狠婷婷综合久久久久久妖精 | 久久久精品天堂 | 欧美一二三四成人免费视频 | 久久综合久| 日韩精品av一区二区三区 | 国产精品欧美一区二区三区不卡 |