0
votes

I have a very weird problem. I have a development environment where I develop a ASP.NET MVC Application, in this environment everything works. Especially in the Application there is a certain AJAX call which calls on a controller and passes data, the controller just needs to update the database with the passed information.Everything works!.

However I hop onto the server with everything setup just as development environment(database,connection strings all that). An everything works fine, login functions as well as other database saving functions and controller actions seems to work fine. Except for ONE controller that return a 500 Internal Server Error.

I asked around and everyone wants to see the logs. In the event viewer there are no logs pertaining to this 500 Internal Server Error. IIS logs however did provide something,but the information does not give specifics on what is causing the 500 Internal Server Error.

I know what a 500 Internal Server Error is and I know its a generic error for a variety of problems, however after looking at the logs I cannot figure out why this specific controller action is giving a 500 error when it is live on the production server BUT no problems when doing it in the development environment-very weird.

Browser Console

enter image description here

IIS Normal Logs

enter image description here

IIS Failed Request Tracing on 500

enter image description here

4
Can you try to connect to to the production DB while debugging? It might be a problem with the dataA. Roussos
What exactly do you mean? Connect to the database on the production server using Visual Studio debugging?moonninja
Exactly. Connecto to the db while debugging from visual studioA. Roussos
You the man @A.Roussos. I still haven't fixed the problem however I got some information I feel comfortable using to solve the problem. I just didn't think that far to install and use Visual Studio on the production server for debugging- damn. Thank anyways.moonninja

4 Answers

0
votes

I had similar problem 2 weeks ago and also had posted about it in stackoverflow [asp.net web api: only during sql connection - HTTP 500 Error occurs : Local host is currently unable to handle request.

After hours of looking into the issue, it was figured out as a stored procedure missing in database.

Not sure whether it will help you with the problem, but hope it can give you some lead to resolve the problem.

0
votes

Following @A.Roussos's advice to use Visual Studio debugging on the PRODUCTION SERVER (might seem obvious for me it wan't haha), I got some information.

My problem is that before I save data to the database I parse a string to double using the parse function. Example

double a = Double.Parse(mystring);

The problem however is apparently the parse function is reliant on your regional settings(CultureInfo). So I just added the following information to the code

double a = Double.Parse(mystring,System.Globalization.CultureInfo.InvariantCulture);

Something to note is that my application didn't crash when I got the 500 Internal Server Error, I didn't have a clue as to what could cause it.After using Visual Studio I got sufficient information to use and google and figure this thing out.

What killed me was that the application(or the one specific controller action in the application) worked perfectly on the development environment but not on the production environment, something like that has never happened to me and I am glad I got this learning experience.

0
votes

Can you make sure that the URL which you are hitting doesn't has any whitespace in it?

0
votes

Have the web.Config set to the custom errors mode as off. You should be able to see the full errors and any additional details associated with these. Many times there are missing aspects in the environment that causes these errors.

It seems that the error is generated by a private method being called in the controller's action method but the error itself is getting eaten (empty catch) or just throw, causing an application failure. Check if the exception handler is present and logging the details somehow.