我有一个在 Windows Azure 上运行的 ASP.NET MVC Web 角色,并在 web.config 中正确设置了 ELMAH。我也有我的 global.asax 忽略 *.axd 路线。在本地,我可以加载 /elmah.axd,但是当我部署到 Azure 时,我在该页面上得到 404。有没有人让 ELMAH 在 Azure 上工作?
问问题
10571 次
3 回答
27
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 工作,您还需要修改 ServiceDefinition.csdef 文件中的以下行:
<WebRole name="WebRole" enableNativeCodeExecution="true">
于 2009-06-10T20:25:58.600 回答
11
还要保护文件,以便只有允许的用户才能查看错误日志!
<location path="admin/elmah.axd">
<system.web>
<authorization>
<allow roles="Administrator" />
<deny users="*" />
</authorization>
</system.web>
</location>
于 2009-07-06T20:25:49.080 回答
9
我认为另外(根据@mat1t here的建议)您可能需要将远程访问设置为 1:
<elmah>
<security allowRemoteAccess="0" />
..............
..............
</elmah>
于 2009-06-15T07:14:21.750 回答