I'm working on an ASP.NET MVC 5 website hosted as an Azure website and I have included ELMAH for error logging. All seems to work fine except I find numerous errors like this one:
A public action method '...' was not found on controller ...
These errors appear mostly when the request comes from a spider bot but they don't seem to produce any errors in the response. Also, all logged controller/action names are totally valid.
E.g. when I run a tool like deadlinkchecker.com on my site, I find hundreds of errors in ELMAH while the tool produces a report with 100% valid links. The path info in ELMAH is also correct.
Why am I seeing these errors?
If you add Head as well as Get then this error will go away and the spider will read your site correctly. As Nathan said, you could turn them off, but you're not fixing the issue really, just ignoring it and you might lose out if spiders cannot read your site 100%
This should work, get fiddler out and try it!
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Head)]
public ActionResult Test()
{
return View();
}
Related
There is something very weird happening on a website I'm working with. When I do a research on Google about a product of the website, the return result is a page that doesn't exist but it doesn't return a 404 error.
The "page.html" does exist, but it is not on the path that Google found, the URL is somehow being created out of nowhere, and since it is inside Joomla, it is causing some visual errors.
I've done some research, and a-lot of people have this kind of error, but normally the page is a 404 or a duplicated version. In my case, the page opens normally, the only thing is that the "page.html" is somehow being put on a path that is not correct. I've already checked inside the folders and there is not a duplicated page inside them.
What could be happening?
If this is a website you host, you can mark the page as a nofollow. If not, Google Search has a beta feature called "About this Result" in which you can leave feedback telling Google the page does not exist. Also, if you reach a 404 page, Web Crawlers will find it on their own eventually.
I am using asp.net mvc 4 for my project. my project is going well. I wonder about a thing.
I make a controller Test and ActionResult Index() this action doesn't need any viewdata or any kind of things.
Now When I test it in my local computer it's should work and it is. no problem.
Now amazing thing is it's doesn't work on server.
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
I am amazed that what happen to my code when everything work without any exception.
Now when I told other people about log they don't have anything. I don't want to install any nuget package on live site to test it. Do someone help me to solve this without adding any error checking module.
How I can check the issue on server.
IIS will log 500 errors in the Event Logs. So assuming you have access to the server, you can check there.
Well, I'm sorry but you have to be willing to do something... If you don't want to install packages like Elmah or enable remote iis debugging or etc... the only other thing that comes to my mind is for you to just start changing random stuff and hope it works. Also, most of these 500 internal server errors are caused by something in the web.config file. Make sure everything is set and good in there.
A very common reason for getting 500 Internal Server error is : Issue in Web.Config file.
Many times one can have some tags not closed properly OR missing Double quotes etc..
In general some syntax error is present most of the times in Web.Config. So make sure atleast you PASS this case.
In my ASP.NET MVC 4 project, I am using the Microsoft.Web.Helpers (from the NuGet package) and my code is a very basic implementation of ReCaptcha. In my view I have:
#ReCaptcha.GetHtml(theme: "clean")
In my controller I have:
Microsoft.Web.Helpers.ReCaptcha.Validate();
The complexity comes with the SSL implementation we are using.
I have added the appropriate settings to my web.config:
<system.net>
<defaultProxy>
<proxy proxyaddress="http://***proxy script settings**"
autoDetect="False"
usesystemdefault="False"
bypassonlocal="True" />
</defaultProxy>
</system.net>
There seems like there is nothing further I can do in terms of config, but I am getting the error message
The remote server returned an error: (404) Not Found
when I hit the recaptcha validate method on the form post method in my controller.
Ive found a number of other answers on here but they all seem to suggest that you change the url, or upgrade. As Im using a NuGet package I would have thought I was using the latest version. Any ideas or links with more information greatly appreciated. Ive already done quite a bit of looking both on this site and google
edit:
I have found that earlier versions of firefox have trouble actually rendering the recapture box given our network conditions, but the latest one is fine. As the validation is done on the controller though, I suppose there is no issue here.
After much pulling of hair and general confusion, I discovered that the problem was that the POST (but not the GET) to the google API was being blocked by our corporate firewall. I had previously discounted this, because I could navigate to the service that recaptcha uses (http://www.google.com/recaptcha/api/verify).
I found this by constructing an HTML page of the requisite parts for the post and submitting it in a browser. The corporate "This page is blocked" appeared - however in code the error that is returned is a 404. The error is somewhat misleading, but this is bizarre behavior from our infrastructure department.
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)