Asp.net mvc 3 and elmah.axd - another 404

Hi everyone, I know that this has been published as the previous question several times, but I reviewed each question and their proposed solutions, and I still can not overcome my 404 problem. I am running Elmah 1.1 32-bit. I referred to ASP.NET MVC - Elmah did not work and returned a 404 page for elmah.axd , but I was out of luck after applying the suggestions.

I am running ASP.NET MVC 3. Here is my web.config:

...

<httpHandlers> <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /> </httpHandlers> <httpModules> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/> <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /> </httpModules> 

...

 <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="dbconn" /> <errorFilter> <test> <jscript> <expression> <![CDATA[ // @assembly mscorlib // @assembly System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a // @import System.IO // @import System.Web HttpStatusCode == 404 || BaseException instanceof FileNotFoundException || BaseException instanceof HttpRequestValidationException /* Using RegExp below (see http://msdn.microsoft.com/en-us/library/h6e2eb7w.aspx) */ || Context.Request.UserAgent.match(/crawler/i) || Context.Request.ServerVariables['REMOTE_ADDR'] == '127.0.0.1' // IPv4 only ]]> </expression> </jscript> </test> </errorFilter> 

I ignored my .axd routes using: routes.IgnoreRoute ("{resource} .axd / {* PathInfo}");

I run the site in IIS7, 32-bit mode is enabled. I tried many different configuration options, but all of this did not help. Any ideas?

Thanks Shan

+4
source share
5 answers

My bad. The following .axd routing rule was ignored after matching default routes. The default route matching rule matched the URL elmah.axd. I probably did not understand that the rules for ignoring should be indicated above this route. Thank you all for your help!

  routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

Just moving routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); before displaying the default route, resolves this issue.

+3
source

Copy the .dll to the trash and the link ... add the default elmah values ​​to configSections

Do not put the handler inside system.webServer, as mentioned above, try executing the system.web section like this in your web.config.

 <system.web> <httpHandlers> <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /> </httpHandlers> </system.web> 

just leave your global.asax as default:

 routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

go to your local axd location

then if you are working, lock it using the Gedas configuration section mentioned above.

+2
source

Have you tried this?

 <configuration> <system.webServer> <handlers> <add name="elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /> </handlers> </system.webServer> </configuration> 

Also be sure to pin the location of elmah.axd to regular users:

 <location path="elmah.axd"> <system.web> <authorization> <allow roles="Admin" /> <deny users="*" /> </authorization> </system.web> </location> 
+1
source

I was getting a 404 error because the SQLServer Compact database exceeded the default maximum file size. Just deleted the SDF data file and 404 left.

+1
source

In asp.net mvc 3 global.asax.cs file

  public static void RegisterGlobalFilters(GlobalFilterCollection filters) { //filters.Add(new HandleErrorAttribute()); } 

HandleErrorAttribute will swallow all exceptions, leaving nothing for ELMAH to handle.

See the Joe blog http://joel.net/wordpress/index.php/2011/02/logging-errors-with-elmah-in-asp-net-mvc3-part1/

0
source

Source: https://habr.com/ru/post/1341742/


All Articles