如何配置 ELMAH 以使用 Windows Azure?我在 Elmah.axd 上收到 404 [英] How to configure ELMAH to work with Windows Azure? I get a 404 on Elmah.axd

查看:20
本文介绍了如何配置 ELMAH 以使用 Windows Azure?我在 Elmah.axd 上收到 404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Windows Azure 上运行的 ASP.NET MVC Web 角色,并且在 web.config 中正确设置了 ELMAH.我也有我的 global.asax 忽略 *.axd 路由.在本地,我可以加载/elmah.axd,但是当我部署到 Azure 时,我在该页面上收到 404.有没有人让 ELMAH 在 Azure 上工作?

I have an ASP.NET MVC web role running on Windows Azure and have setup ELMAH properly in the web.config. I also have my global.asax ignore *.axd routes. Locally, I am able to load /elmah.axd, however when I deploy to Azure, I get a 404 on that page. Has anyone gotten ELMAH working on Azure?

推荐答案

Azure 基于 Windows Server 2008 和 IIS7.这意味着您需要填充 web.config 文件的 system.webServer 部分.

Azure is based on Windows Server 2008 and IIS7. This means that you need to populate the system.webServer part of the web.config file.

elmah 源代码中包含的示例文件包含您需要输入的详细信息.

The sample file included with elmah's source code contains the details that you need to put in.

<system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <modules>
    <remove name="ScriptModule" />
    <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
  </modules>
  <handlers>
    <remove name="WebServiceHandlerFactory-Integrated"/>
    <remove name="ScriptHandlerFactory" />
    <remove name="ScriptHandlerFactoryAppServices" />
    <remove name="ScriptResource" />
    <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
         type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
         type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add name="elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
  </handlers>
</system.webServer>

在上述 xml 块中有 2 行 elmah 行,您需要包含这些行,并且该部分通常应该包含大部分(如果不是全部)这些元素.

There are 2 elmah lines in the above block of xml that you will need to include, and the section in general should contain most if not all of those elements anyway.

不再需要,因为现在默认启用:

No longer required as this is now on by default:

<打击>要使 Elmah 正常工作,您还需要修改 ServiceDefinition.csdef 文件中的以下行:

For Elmah to work you will also need to modify the following line in your ServiceDefinition.csdef file:

<WebRole name="WebRole" enableNativeCodeExecution="true">

这篇关于如何配置 ELMAH 以使用 Windows Azure?我在 Elmah.axd 上收到 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆