哪个重定向更好 - web.config 或 global.asax

发布于 2024-08-19 16:02:43 字数 140 浏览 8 评论 0原文

我需要将应用程序中的一些旧页面重定向到新页面。我认为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

薄荷→糖丶微凉 2024-08-26 16:02:43

如果我将现有页面映射到新页面,我会保留旧页面并将 301 永久重定向刷新到客户端。假设这是一个公共网站,这将保留 SEO。

 Response.StatusCode = 301;
 Response.Status = "301 Moved Permanently";
 Response.RedirectLocation = location; // static, configuration, or database
 Response.End();

总的来说,我会选择重新路由而不是重写。两个很棒的链接是:

有关重新路由之前的一些不同方法的概述,请查看 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.

 Response.StatusCode = 301;
 Response.Status = "301 Moved Permanently";
 Response.RedirectLocation = location; // static, configuration, or database
 Response.End();

Overall I would go with rerouting instead of rewriting. Two great links for this are:

For an overview of some different approaches prior to rerouting check out Scott Gu's Tip/Trick: Url Rewriting with ASP.NET

太阳哥哥 2024-08-26 16:02:43

使用 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.

赠意 2024-08-26 16:02:43

这是通过 HttpHandler 编写重定向的方法之一。

http://www.developerfusion.com/article/4643 /在-aspnet中实现http-handlers/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文