How to solve the 500 Server error in asp.net mvc without enable the error show stuff - asp.net-mvc

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.

Related

ASP .NET MVC 500 Internal Server Error - on Get and Post - same application / different servers

I'm trying to help our System Admins here, so please don't beat me up for my lack of knowledge. We can run the application locally and we can build and deploy to our Test Server and the application reports work as expected. But when we deploy to our Production Server, many of the Get and Post Ajax calls are getting 500 errors. Essentially, all reports run everywhere EXCEPT on the Production Server.
This is an ASP .NET MVC application with the views being Razor HTML and JavaScript. The model, controllers, and services are all in C#. IIS 8.5 web server and SQL Server for the database.
I've Googled and tried everything I could find. More detailed errors show us the service call that fails along with the parameters and all looks good. Again the application reports run fine in all environments other than the Production Server. Does anyone have any idea why this is happening and what we should be looking at to resolve the issue?
Thank you in advance.
Just turn off custom errors in the web.config file
<system.web>
<customErrors mode="Off">
</system.web>
and then open up the development tools in a browser during one of the GET requests and replay the GET yourself. Should get the exact error message back.
It took us all day to figure out that one of the parameter tables did not have the appropriate permissions. Which would explain why some reports ran while others consistently returned a 500 error.

Error 405 on PUTs, "ignoreme.rastahook" in IIS log

We have an Asp.Net application with OpenRasta, and when we deploy it on most of our IISes (7.5), it works fine. In one installation though, for PUT requests, the client receives "405 Method not allowed" errors, and the log shows entries like:
2011-11-15 01:18:20 192.168.0.164 PUT /myapp/ignoreme.rastahook - 80 - 192.168.0.131 AClient 405 0 0 57
ignoreme.rastahook seems to come from OpenRasta's rewriting in OpenRastaModule.cs:
HttpContext.Current.RewritePath(VirtualPathUtility.ToAppRelative("~/ignoreme.rastahook"), false);
The GETs and POSTs work fine though, not sure though if the HTTP method really is what makes the difference. Any idea on what might be going on or where to start debugging? My current guess would be some IIS configuration difference between the working servers and the one that doesn't.
OpenRasta version is 2.0.3, and we run the app on .net 4.
Update:
Fwiw, when changing the verb attribute of the OpenRasta handler mapping from "*" to "GET,POST" in the web.config of my server that works, I get a "ignoreme.rastahook" in the log file as well for the PUTs, but with a 404, not a 405, so that seems to be different from the issue described above.
Update 2
I figured that when I enable WebDAV, I can reproduce the 405 / ignoreme.rastahook issue. Which lead me to https://github.com/openrasta/openrasta-stable/wiki/Installing-OpenRasta-Under-IIS , that states that
please be aware that the WebDAV module can cause problems with IIS 7.5
Update 3
I verified that WebDAV is what caused the problem on that other server, but if anyone knows how to fix the problem without disabling WebDAV altogether, I'd appreciate it.
The problem as you've seen comes from WebDAV. There is no know way that I have found bar adding the entries in your web.config to disable webdav.
This has been added to the wiki page in question.

MVC.Net site is throwing a 404 error for a resource/page that isn't being called

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.

MVC.NET 404 outside of Domain

I am trying to get a demo site for a client setup. This is the 1st application my company is doing in MVC.NET, so I get to experience all the new things to find out (and all the headaches it'll cause).
Anyway, the site works fine locally (localhost) and on the server inside our domain. External users not on the domain however, only get 404 errors. I've tried several different settings/ config options I've found on this site, but nothing is working. I don't know if it's a web.config issue or an IIS issue, or even simply a permissions issue (though it has all the same permissions as the other sites we run with Web Forms).
IIS: v7 in intergrated mode.
Windows Server Web
Well, because you received a 404, the server is being reached okay which is a good sign. (Dealing with firewall issues at a company is always a lot of fun.)
A common problem for something like this is the use of virtual directories to host the website. For example, if the address to your site is http://example.com/MySite/, in MVC that would translate to: /MySite/View/Index.aspx. HOWEVER...if you are using virtual folders, /MySite/ may instead point to another spot on the server (e.g. C:\WebSites\MySite). If you are indeed using virtual paths, make sure you have your files stored at the correct path.
There is a troubleshooting tutorial here: http://support.microsoft.com/kb/248033
thanks for the answers everyone. Turns out it was something with our DNS routing setup with the sub-domains. It was getting rerouted to a place that didn't exist. Our IT guy finally got around to fixing it (ugh!)

Using ELMAH in medium trust

I'm building an ASP.net mvc app, and am having some problems getting ELMAH deployed using xml logging to a medium trust server, though it works fine on my local machine. It keeps getting a 404 error.
The problem might be that the host doesn't allow relative filepaths, so the "~/App_Data" doesn't work for logging. I switched that to:
logPath="\\Something\Something\ID\www.website.com\web\content\App_Data"
in the web.config. The syntax might be completely off, but I've tried a few variations and none of them worked.
I subsequently found this question and added the recommended code to my web.config, but still no luck. Does anyone know how to get ELMAH to work on medium trust?
Thanks!
The asp.net worker process (or the aspnet user) has minimum rights to write into the filesystem. Try a place like c:\temp where everybody can write files. After this check and set access rights for aspnet user.
It turned out that the ELMAH.dll was calling SQLite, which isn't allowed under medium trust, and was causing ELMAH to fail when deployed to medium trust. I needed to download the source code for ELMAH and re-build it without the reference to SQLite. It is now working. Yay!

Resources