哪个重定向更好 - web.config 或 global.asax
我需要将应用程序中的一些旧页面重定向到新页面。我认为 web.config 中的 urlMapping 是实现此目的的有效方法。但还有另一种使用 global.asax 进行重定向的方法。哪一种是最有效的方法。在请求执行的什么时候,这个 asax 和配置文件会出现?
I need to redirect some of the older pages in my application to new pages. I thought urlMapping in web.config is the efficient way to achieve this. But there is also another way to redirect using global.asax. Which one is the efficient way for this. At what point in request execution does this asax and config file comes into the picture?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我将现有页面映射到新页面,我会保留旧页面并将 301 永久重定向刷新到客户端。假设这是一个公共网站,这将保留 SEO。
总的来说,我会选择重新路由而不是重写。两个很棒的链接是:
再见 URL 重写?
有关重新路由之前的一些不同方法的概述,请查看 Scott Gu 的提示/技巧:使用 ASP.NET 重写 URL
If I were mapping existing pages to new ones I would keep the old pages in place and flush a 301 permanent redirect to the client. This will preserve SEO, assuming this is a public site.
Overall I would go with rerouting instead of rewriting. Two great links for this are:
Goodbye URL rewriting?
For an overview of some different approaches prior to rerouting check out Scott Gu's Tip/Trick: Url Rewriting with ASP.NET
使用 URL 重写 ISAPI 过滤器执行重定向 - 它是较低级别的并且将首先运行,因此您不会对 asp.net 引擎造成影响。
我链接的页面还提到了 ASP.NET 路由、它们之间的差异以及如何在两者之间进行选择。
Use the URL Rewrite ISAPI filter to do the redirect - it is lower level and will run first, so you don't take a hit on the asp.net engine.
The page I linked also mentions ASP.NET Routing, the differences between them and how to choose between the two.
这是通过 HttpHandler 编写重定向的方法之一。
http://www.developerfusion.com/article/4643 /在-aspnet中实现http-handlers/
Here is one of way to write redirect by HttpHandler.
http://www.developerfusion.com/article/4643/implementing-http-handlers-in-aspnet/