4

Hi all I know that this has been posted as a prior question several times, but I've gone through each question and their proposed solutions and I'm still not able to surmount my 404 issue. I'm running Elmah 1.1 32-bit. I've referred to ASP.NET MVC - Elmah not working and returning 404 page for elmah.axd but I haven't had any luck after applying the suggestions.

I'm running ASP.NET MVC 3. Here's 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 have my .axd routes ignored using: routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

I'm running the site on IIS7, 32 bit mode enabled. I've tried many different configuration options but all to no avail. Any ideas?

Thanks Shan

5 Answers 5

3

My bad. My .axd ignore route rule was ordered after the default route mapping. The default route mapping rule was matching the URL elmah.axd. I guess I didn't realize that the ignore rules had to be listed above this route. Thanks everyone 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}");

Simply moving routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); before the Default route mapping resolved this issue.

2

Copy the .dll to your bin and reference... add the elmah defaults to configSections

Don't put the handler inside the system.webServer as mentioned above, try system.web section like this instead 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}");

browse to the axd locally

then if working, lock it down with the config section Gedas mentioned above.

1
  • Thanks ScottR, I tried removing the system.webServer config, but I'm still getting the 404. I have the dll in my bin, and it's referenced in my VS.NET project settings. I have the routes.IgnoreRoute() as well. Not sure why it's not working May 18, 2011 at 3:29
1

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 make sure to secure elmah.axd location from regular users:

<location path="elmah.axd">
    <system.web>
        <authorization>
            <allow roles="Admin" />
            <deny users="*" />
        </authorization>
    </system.web>
</location>
3
  • Got that already. I think that I have all of the other config stuff as required in <modules>...</modules> as well Mar 7, 2011 at 4:26
  • Is the server local or remote? If remote, you may need to enable remote access <elmah> <security allowRemoteAccess="1" /> </elmah> You might also want to try commenting out <errorlog> section to see if it's causing your problem. Mar 8, 2011 at 0:52
  • It's a local server, I have allowRemoteAccess = 1, and I've commented out all of the <errorlog> sections. Elmah was successfully logging to my SQL Server DB. The only issue is I can't access the elmah.axd resource. Very strange! Apr 29, 2011 at 2:19
1

I was getting a 404 error due to the SQLServer Compact database being over the default max file size. Just deleted the SDF data file and 404 went away.

0

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 Joe's blog http://joel.net/wordpress/index.php/2011/02/logging-errors-with-elmah-in-asp-net-mvc3-part1/

1
  • Thanks, I tried it out and reviewed the blog, but no luck - I'm still getting a 404 on trying to access elmah.axd Apr 29, 2011 at 2:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.