本文介绍了HttpModule使用IIS6重写URL,没有无扩展名的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用带有2.0版框架和IIS6的asp.net的Intelligencia URLRewriting模块。我们的网址通常没有扩展名。

We are using the Intelligencia URLRewriting module for asp.net with version 2.0 of the framework and IIS6. Our URLs typically have no extension.

据我所知,如果没有毯子通配符(导致其他问题),IIS6无法真正处理这种情况。

I understand that IIS6 cannot really deal with this situation without a blanket wildcard (which causes other problems).

但是,它的工作原理!有时。在其他时候(例如在一台开发者的机器上,当我在应用程序上指向另一个虚拟目录时,在我的机器上)它没有。通过它不起作用我的意思是配置的HttpModules永远不会被击中。

However, it works! Sometimes. At other times (e.g. on one dev's machine, and on my machine when I point a different virtual directory at the app) it doesn't. By "it doesn't work" I mean the configured HttpModules never even get hit.

任何人都可以解释这个吗?

Can anyone explain this?

谢谢。

推荐答案

事实证明发生的事情如下:

So it turns out what was happening was the following:


  • 请求进入(比如)

  • IIS无法找到这个因此我们得到了一个404

  • 我们偶然设置了一个自定义错误页面strong> IIS 适用于404s

  • 此错误页面将引用网址粘贴在404 error.aspx页面的末尾

  • 所以我们得到一个重定向进入asp.net的行:

  • request comes in to (say) http://website/products/productid
  • IIS can't find this hence we get a 404
  • by chance we have a custom error page set up in IIS for 404s
  • this error page sticks the referring URL on the end of the 404 error.aspx page
  • so we get a redirect coming into asp.net along the lines of:

我们的URLRewriting正则表达式现在以这样的方式设置他们放弃了error.aspx位并处理了,就像它是实际网址

our URLRewriting regexes were now set up in such a way that they discarded the error.aspx bit and dealt with http://website/products/productid as if it were the actual URL

我想这可能证明是有用的某人的kludge,但我们正在转向isapi过滤器。一个单挑是默认情况下会导致重定向的紧密循环!

I guess this could prove to be a useful kludge for someone, but we're moving to an isapi filter. One heads-up is that this will by default lead to a tight loop of redirects!

这篇关于HttpModule使用IIS6重写URL,没有无扩展名的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 09:45