简体   繁体   English

global.asax重写无法实时进行

[英]global.asax rewriting not working live

I have implemented a URL rewriting in the global.asax file, it works perfectly on my machine but not on the live enviroment. 我已经在global.asax文件中实现了URL重写,它可以在我的机器上完美运行,但不能在实际环境中运行。 Any idea what shall I look at to solve the problem? 我知道该如何解决这个问题? Thanks 谢谢

First make sure that you have IIS set to pass all relevant URIs to the ASP.NET engine. 首先,请确保已将IIS设置为将所有相关的URI传递给ASP.NET引擎。 If the paths all end with a limited number of so-called "extensions" (eg .html, .png to make the URI look like a file-path with a file-extension) then you need just map this particular extension (copy-paste from that for .aspx). 如果所有路径都以有限数量的所谓“扩展名”结尾(例如,使URI看起来像带有文件扩展名的文件路径的.html,.png),则只需映射此特定扩展名(复制-从中粘贴.aspx)。

If you need it to handle (or at least examine and see if it should handle) a wider range of URIs you need to set a wildcard handler. 如果您需要它来处理(或至少检查并查看它是否应该处理)更广泛的URI,则需要设置一个通配符处理程序。 Different versions of IIS differ in how this is done (IIRC 5.0 to 6.0 was when the change happened). IIS的不同版本在完成方式上有所不同(更改发生在IIRC 5.0到6.0之间)。 If the version has a place to enter wildcard mappings on the part of the dialog that deals with script-mappings (or "handler mappings" from 7.0 on) then use this, if not, define a mapping for .* (don't worry about the period, it will still match URIs even if they don't have one). 如果该版本在处理脚本映射的对话框的一部分上可以输入通配符映射(或从7.0开始的“处理程序映射”),则可以使用它,如果没有,则为。*定义一个映射(不用担心)关于该期限,即使它们没有URI,它仍将匹配URI。

There's other things that could be going wrong, but this is your starting point, and if it isn't right, it'll certainly cause this problem. 还有其他可能出错的地方,但这是您的出发点,如果不正确,肯定会导致此问题。

The web server built into Visual Studio uses the ASP.NET engine to handle all file types, but IIS only uses the ASP.NET engine to handle file types that actually are executed. Visual Studio内置的Web服务器使用ASP.NET引擎处理所有文件类型,但是IIS仅使用ASP.NET引擎处理实际执行的文件类型。

So, the Application_BeginRequest event (and similar) in the global.asax file only happens for file types like .aspx or .asmx , not file types like .html , .css or .jpg . 因此,global.asax文件中的Application_BeginRequest事件(及其类似事件)仅在.aspx.asmx类的文件类型中发生,而在.html.css.jpg类的文件类型中不发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM