路由属性破坏了 Elmah url
Routing attribute broke Elmah url
最近我在一个 MVC5 网站中使用了路由属性,该网站也使用了 Elmah 模块但是已经很久了。一旦我完成了所有路由的实施,Elmah url 就坏了,再也找不到了。要访问和显示 Elmah 错误,该网站使用 iframe :
<iframe src="@Url.Content("~/elmah.axd")"></iframe>
所以我找不到任何解决方案来恢复它。仍然记录错误,我可以从目录中打开它们,但是从上面的 url 中找不到页面。
谢谢,
大卫
编辑
这里是web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301879
-->
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup><!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<connectionStrings>
...
</connectionStrings>
<appSettings>
<add key="Environment" value="local" />
<add key="webpages:Enabled" value="false" />
<add key="webpages:Version" value="3.0.0.0" />
<add key="CachedExpiration" value="00:05:00" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="elmah.mvc.disableHandleErrorFilter" value="true" />
</appSettings>
<system.web>
<authentication mode="None" />
<httpRuntime targetFramework="4.5" />
<compilation debug="true" targetFramework="4.5" />
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules></system.web>
<system.webServer>
<!--<httpProtocol>
<customHeaders>
<add name="X-Frame-Options" value="ALLOW-FROM" />
</customHeaders>
</httpProtocol>-->
<modules>
<remove name="FormsAuthentication" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /><add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" /><add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" /></modules>
<validation validateIntegratedModeConfiguration="false" /><handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers></system.webServer>
<runtime>
...
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on remote access and securing ELMAH.
-->
<security allowRemoteAccess="false" /></elmah><location path="elmah.axd" inheritInChildApplications="false">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on using ASP.NET authorization securing ELMAH.
<authorization>
<allow roles="admin" />
<deny users="*" />
</authorization>
-->
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>
</system.webServer>
</location></configuration>
为了解决这个问题,除了这些包之外,我还必须添加 Elmah.Mvc 包:
<package id="elmah" version="1.2.2" targetFramework="net452" />
<package id="elmah.corelibrary" version="1.2.2" targetFramework="net452" />
在我的项目中,将 .axd 字符串删除到 iframe url,如下所示:
<iframe src="@Url.Content("~/elmah")"></iframe>
激活路由属性后一切正常。
最近我在一个 MVC5 网站中使用了路由属性,该网站也使用了 Elmah 模块但是已经很久了。一旦我完成了所有路由的实施,Elmah url 就坏了,再也找不到了。要访问和显示 Elmah 错误,该网站使用 iframe :
<iframe src="@Url.Content("~/elmah.axd")"></iframe>
所以我找不到任何解决方案来恢复它。仍然记录错误,我可以从目录中打开它们,但是从上面的 url 中找不到页面。
谢谢,
大卫
编辑
这里是web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301879
-->
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup><!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<connectionStrings>
...
</connectionStrings>
<appSettings>
<add key="Environment" value="local" />
<add key="webpages:Enabled" value="false" />
<add key="webpages:Version" value="3.0.0.0" />
<add key="CachedExpiration" value="00:05:00" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="elmah.mvc.disableHandleErrorFilter" value="true" />
</appSettings>
<system.web>
<authentication mode="None" />
<httpRuntime targetFramework="4.5" />
<compilation debug="true" targetFramework="4.5" />
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules></system.web>
<system.webServer>
<!--<httpProtocol>
<customHeaders>
<add name="X-Frame-Options" value="ALLOW-FROM" />
</customHeaders>
</httpProtocol>-->
<modules>
<remove name="FormsAuthentication" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /><add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" /><add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" /></modules>
<validation validateIntegratedModeConfiguration="false" /><handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers></system.webServer>
<runtime>
...
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on remote access and securing ELMAH.
-->
<security allowRemoteAccess="false" /></elmah><location path="elmah.axd" inheritInChildApplications="false">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on using ASP.NET authorization securing ELMAH.
<authorization>
<allow roles="admin" />
<deny users="*" />
</authorization>
-->
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>
</system.webServer>
</location></configuration>
为了解决这个问题,除了这些包之外,我还必须添加 Elmah.Mvc 包:
<package id="elmah" version="1.2.2" targetFramework="net452" />
<package id="elmah.corelibrary" version="1.2.2" targetFramework="net452" />
在我的项目中,将 .axd 字符串删除到 iframe url,如下所示:
<iframe src="@Url.Content("~/elmah")"></iframe>
激活路由属性后一切正常。