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.
Related
I am getting attached exception from one of the server but same code base working on other environment and code base does not have config related to this. Seems something available on sitecore instance creation itself.
that keepAlive.aspx is available in the respective farm and It is opening when I hit the same from browser
I have file in folder "/UploadDir/TextFile1.txt"
I need:
download file if it exists
if file not exists (for example url :"/UploadDir/TextFile2.txt") should be shown custom errors message.
But now my mvc application not handle any requests to missed or existing files, when i place breackpoint on Application_BeginRequest and try to request text file - nothing occurred.
Besides i tryed to override HttpNotFound and HandleUnknownAction but same unsuccessfully.
Who can help me how to hande request to file if it exists or show custom error if it not found.
ps. route configuration is default
It sounds like the request GET /UploadDir/TextFile1.txt is being handled by IIS and not being passed into the ASP.NET pipeline. IIS will attempt to serve the content using its static file handler due to the .txt extension, and discover the file does not exist, issuing a 404.
You need to change your configuration to make these requests be passed to the ASP.NET handler for further processing. The exact details of that depend on your version of IIS.
Ok, this one is killing me. It makes no sense at all... I've setup a simple MVC.Net project. Everything appears to work fine. I get the typical 404 errors, and wanted to change that so I started looking into that... That got me poking around in the Application_Error method in the global.asax. It all appears to work as I would expect.
Here's the problem. I put the following line of code (just this line) in the Application_Error method and made a breakpoint to see what the error traffic was like so I could test things, etc.
Exception ex = Server.GetLastError();
I'm running the project in debug, and it comes back with an HttpException with an error code 404
The controller for path
'/Content/jquery-ui-1.8.7.custom.min.js'
was not found or does not implement
IController.
So far nothing too strange, right? So, I did a search for this offending call. I used the Visual Studio Find function and searched Entire Solution for /Content/jquery-ui-1.8.7.custom.min.js. There were no calls to this file. I searched for jquery-ui-1.8.7.custom.min.js and found all the expected calls to that file which look for it in the /Scripts/ directory.
In the /Content/ directory I have my .css files, and some images in the Images subdirectory...
I'm hoping there is just something strange that I don't know about with MVC.Net that you guys have already figured out that causes this quirkiness. It just makes no sense... I could see getting the 404 if there was a call to that file, but there isn't...
Any guidance on even some troubleshooting ideas would be helpful at this point. I'm stumped...
Thanks guys!
Just a suggestion to help you debug: Download Fiddler and check the actually HTTP requests being made. Note: When debugging using localhost, make a new hosts entry and point 127.0.0.1 to some other name, otherwise Fiddler won't track the requests.
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)
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://mysite.com/Content/MyFlashApp/myflash.swf cannot load data from http://www.mysite.com/Home/SaveData.
at Main/encodeAndSave()
This post says that the problem can be caused by the wrong path being specified on the server side. You don't give a whole lot of information with your question - is this the problem you're having?
Other options from the same post are:
Trying to upload a file that is too big
Invalid filenames (e.g. containing an apostrophe)
A proxy server messing with the upload
When doing a Post to a web app from a flash app, you must specify the URLRequest's server path to be the exact same as what you're on.
If you specify:
http://www.mysite.com
http://mysite.com throws the security error above.
see here for more details on cross-domain security issues and how to resolve them.