如何配置 ELMAH 以与 Windows Azure 一起使用? 我在 Elmah.axd 上收到 404

发布于 2024-07-22 07:48:16 字数 187 浏览 3 评论 0原文

我有一个在 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

裸钻 2024-07-29 07:48:16

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

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

<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 行,您需要包含这些元素,并且该部分一般应包含大多数(如果不是全部)这些元素反正。

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


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

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

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.

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>

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.

EDIT: No longer required as this is now on by default:


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

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

伪心 2024-07-29 07:48:16

还要保护文件,以便只有允许的用户才能查看错误日志!

<location path="admin/elmah.axd">
    <system.web>
        <authorization>
            <allow roles="Administrator" />
            <deny users="*" />
        </authorization>
    </system.web>
</location>

Also secure the file so only allowed users can view the error logs!

<location path="admin/elmah.axd">
    <system.web>
        <authorization>
            <allow roles="Administrator" />
            <deny users="*" />
        </authorization>
    </system.web>
</location>
熊抱啵儿 2024-07-29 07:48:16

我认为另外(对于@mat1t )您可能需要将远程访问设置为 1:

<elmah>
<security allowRemoteAccess="0" />
..............
..............
</elmah>

I think additionally (to what suggested by @mat1t here) you may need to set remote access to 1:

<elmah>
<security allowRemoteAccess="0" />
..............
..............
</elmah>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文