【问题标题】:Global.asax Application_BeginRequest not firing unless physical file exists - 404除非物理文件存在,否则 Global.asax Application_BeginRequest 不会触发 - 404
【发布时间】:2014-03-05 12:27:48
【问题描述】:

我在 Global.asax 中使用 URL 重写 (HttpContext.Current.RewritePath(...)),因此物理文件大多不存在。 一切正常,直到我不得不从 IIS (8.5) 中删除站点并再次添加它。

现在我得到 404 not found 对于每个请求。示例http://localhost/site/article123 Global.asax Application_BeginRequest 事件甚至没有触发。

但是,如果我将在文件夹 /site/article123 中添加空的 default.aspx 文件,那么一切都开始正常工作,并且 URL 被正确重写。

文件没有变化,应该是IIS配置的问题。

我在 web.config 中确实有以下内容:
<modules runAllManagedModulesForAllRequests="true">

IIS 中的项目设置为具有应用程序池 .NET v2.0 Classic 的应用程序

编辑:
IIS 8.0 中的相同情况

【问题讨论】:

    标签: asp.net .net iis url-rewriting global-asax


    【解决方案1】:

    问题在于Managed Pipeline Mode 设置为classic。通过将应用程序池从.NET v2.0 Classic 更改为.NET v2.0classic 切换到integrated 对问题进行了排序。

    据我了解:在classic 模式下,IIS 管理请求,而在intergated 模式下,传入的 IIS 请求映射到 ASP.NET 引擎。

    有关管道模式的更多信息:What is the difference between 'classic' and 'integrated' pipeline mode in IIS7?

    【讨论】:

    • 我一直在集成。 30 个池工作,只有 1 个单池不工作。然后我只是更改为经典并返回集成,现在它正在工作。
    【解决方案2】:

    您需要在 IIS 8.5 下安装 ReWrite Module

    使用 Web Installer Platform 进行安装。

    【讨论】:

    • 我认为我不需要安装 ReWrite 模块。正如我所说,我使用HttpContext.Current.RewritePath(...) 进行 URL 重写,并且 AFAIK 它不依赖于重写模块。无论如何,我确实安装了 ReWrite 模块,所以这不是问题。
    • 没有.net v4.5 Pool这样的东西。有没有人让这个工作?我有 dotnet 4.0 池和集成,但 Application_BeginRequest 仍然不会在 IIS8 上触发。
    猜你喜欢
    • 2019-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多