Why are users taken to /?aspxerrorpath=/UrlRouting.axd - asp.net-mvc

I was just looking at analytics for an ASP.NET MVC 1 site running on Mono.
I saw that once in a while users are brought to this URL: /?aspxerrorpath=/UrlRouting.axd
What would cause this?

an error?
/
is your error handler
/UrlRouting.axd
threw the exception.
Look at your customErrors section in web.config

Unless you are clearing all the items in your HttpContext.Items (not common), the error is occurring between the two HttpApplication events PostResolveRequestCache and PostMapRequestHandler. The only event between them is MapRequestHandler. You can probably find the cause of this error by looking for any HttpModules that subsribe to the MapRequestHandler event.

Related

Why Elmah set 0 for code in internal errors?

Recently I created an ASP.NET MVC 5 application and installed Elmah.MVC.2.1.2 from the nugget package management on it.
Every things looks OK and Elmah logs all errors but when it logs internal errors it set 0 for code. I think it should set 5xx error code for theirs, am I right or not? If I'm right, where should I configure it?
Thanks in advanced (:
ELMAH only shows the status code, if the thrown exception is of type HttpException. You can either catch the exception inside the controller and re-throw it as a HttpException or write a filter converting uncaught exceptions to HttpException.

Exceptions in N2cms page

i'm using n2cms + asp.net mvc,
when the site is uploaded to a webserver, and an exception is thrown in the aspx page, the page appear blank, and there is nothing in the page, even if i turned off the CustomErrors in web.config
but when the site is running on my computer visual studio simply show me the exception,
is there a way to catch the exception in this situation?
This may be due to your hosting configuration. You could take a look at ELMAH for an easy way of logging exceptions.
You can handle all global errors in your Global.asax's method called Application_Error - http://msdn.microsoft.com/en-us/library/24395wz3.aspx . It will work for simple cases. But I strongly recommend to use ELMAH
N2CMS makes calls to SwallowExceptions(). This is why you are receiving a blank page instead of an exception. You could look for that method call and comment it.

How can I get 404 to work with Elmah and the HandleErrorAttribute written for Elmah in asp.net mvc?

I have implemented Elmah in one of my ASP.NET MVC projects. In addition I did the following:
I implemented the ElmahHandleErrorAttribute written by Atif Aziz in this post
I added the attribute to all my controllers
I have setup Elmah to filter out 404 errors since I do not want to log those
I added an Error.aspx view in the Shared folder that I wish to use for all my errors.
My customErrors in the Web.Config are turned on and I have not specifed any error pages in it as I shouldn't have to.
In one of my controllers I have the following code:
if (model == null)
throw new HttpException((int)HttpStatusCode.NotFound, "Project not found");
I simply want to display a 404 if a record can not be found in the database. For some reason my Error.aspx page will not display for a 404 error. Instead it displays the generic asp.net "the resource can not be found" page. I have tried to remove the 404 filter setup in Elmah but that does not change anything.
The interesting part is if I change the error from NotFound to say InternalServerError the Error.aspx page shows up just fine.
Does anyone have any pointers as to why this is?
I have not used Elmah beyond creating a sample app - but maybe because a 404 is not application error? If my understanding is correct, a 404 error gets pushed back to IIS which in turn displays the error message you are seeing. Also, I believe that the web.coin
If i understand correctly, you may want to amend your approach and build use this instead or set the Response.StatusCode to 404 (Check out Jeff's answer in the linked question)

set switch to trigger custom filter in asp.net mvc for exception handling

is there something I need to "turn on" to allow my asp.net mvc application to utilize custom exception filters?
I posted in here last week with code samples to a custom filter I wrote that should catch and handle a custom exception but for some reason I keep getting an error on my throw line indicating that the exception was not handled by user code.
I had a response last week from someone who indicated they copied and pasted my code exactly and it worked fine for them. This makes me wonder if maybe I need to set something web.config or something to tell the app to use the custom filter for unhandled exceptions.
please advise,
TIA
How are you implementing? If you inherit from FilterAttribute and IExceptionFilter class/interface, you will have to ensure the exception content has the exceptionhandled flag set to true to prevent the error, I believe.

ASP.NET MVC Unhandled Exceptions on Images?

I haven't been able to replicate the exception when I browse my site... but I found out about this through my event logger (it emails my cell phone when an unhandled exception occurs).
Here's the exception:
The controller for path
'/Content/UsrImg/ImageFileName.jpg'
could not be found or it does not
implement IController.
What I think happened is that the image that Google (or perhaps a proxy server) had cached no longer existed. When trying to go directly to that image, it load the "Page not found" friendly error I wrote.
But should it be throwing an unhandled exception on 404 errors? Seems a bit strange to me. Perhaps there something I can do in the routing to fix this?
I just ran into this issue yesterday. Check to see if the image is on your server. My problem was Build Action for the file was set to none, but it should be set to Content. It was not including the file when I published the website.
You don't need to change routing, as the Content directory should be invoke Routing.

Resources