在 IIS 7.5 上使用 Asp.Net 4.0 处理旧 *.asp 链接的最佳方法?
我们仍然有很多传入的 URL 指向我们旧的 .asp 页面。新的 .aspx 页面的名称与旧的 .asp 页面相同,并且接受的值基本相同,因此它们几乎可以互换。不幸的是,我们仍然收到对旧 .asp 页面的 POST 和 GET 请求。 我们在 Asp.Net 2.0 应用程序中处理这些 .asp 请求,方法是在 web.config(system.webserver 部分)中添加以下内容:
<handlers>
<add name="ASPClassicForRedirectToASPX"
path="*.asp"
verb="*"
modules="IsapiModule"
scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"
resourceType="Unspecified"
preCondition="classicMode,runtimeVersionv4.0,bitness32" />
</handlers>
然后在 BeginRequest 中检查 url 是否以 .asp 结尾,如果是,则执行 RewritePath 来.aspx
现在我们已经迁移到 asp.net 4.0,我开始想知道是否有更好的方法来处理这个问题,并且仍然保持与旧的 .asp url 的向后兼容性?
We still have a lot of incoming urls pointing to our old .asp pages. The new .aspx pages are called the same as the old .asp pages, and accept mostly the same values, so they are pretty much interchangeable. Unfortunately we still get both POST and GET requests to the old .asp pages.
We handled these .asp requests in our Asp.Net 2.0 app by adding this in our web.config (system.webserver section):
<handlers>
<add name="ASPClassicForRedirectToASPX"
path="*.asp"
verb="*"
modules="IsapiModule"
scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"
resourceType="Unspecified"
preCondition="classicMode,runtimeVersionv4.0,bitness32" />
</handlers>
and then checking in BeginRequest if the url ends with .asp, and if it does, do a RewritePath to .aspx
Now we have migrated to asp.net 4.0 and I started to wonder if there is a better way to handle this, and still keep backwards compatibility with the old .asp urls?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果还没有准备好,我会做的事情是像 BeginRequest 而不是 url 重写(如果可能):
使用 301 永久重定向,您将确保所有爬虫和其他内容都会将其链接更改为应该重复使用的正确链接您接到的 .asp 页面的电话数量很多。除此之外,您有时会被旧的直接链接到您的 ASP 页面所困扰,我猜您将不得不放弃它们。不能永远支持旧的东西,即使那会很棒:)
what i would do if not allready the case is something like that in the BeginRequest instead of url rewrite (when possible) :
using a 301 permanent redirect you will make sure that all crawlers and stuff will change their link to the right one that should reduse the calls u get to your .asp pages by a lot. other than that you are stuck with the old direct links to your asp pages at some point im guessing you will have to let them go. Cant support old stuff forever even tho that would be awesome :)