XMLHttpRequest Internal Server Error 500 Debugging - asp.net

I have an api application which are givin me quite a headache. So in desperation I'm posting my problem here.
Short version
In short I need to know how I can debug my application to figure out what is causing the 500 Internal Server Error, I've tried to look into the Event log, but it doesn't tell me much besides which requests have failed, nothing about why they failed. So I honestly have no clue where to go from here.
The API is an ASP.Net MVC project and is hosted on an IIS 8.5 Windows Server 2012 R2

try sending a get request and reading the response. To get an increased level of error info, enable remote errors
https://technet.microsoft.com/en-us/library/bb684665.aspx

Related

Azure VM IIS HTTP Status Codes Changed

I have a couple Azure VMs behind a Basic Load Balancer with an HTTP URL Health Probe for the Backend Pool. To mark a server down, that URL returns Status Code 503 (Service Unavailable), but when I call that page from those VMs, the Status Code returned is 403. That still has the desired effect, I suppose, of marking the server down - but I dont understand why the code I set has changed.
This is from an ASP.NET web forms application on the VMs. I look at developer tools in the browser, and from my local machine or from a Dev server on our local network, that page returns Status Code 503, but calling that page from the VMs in Azure, the Status Code is 403.
Here's where I set the Status Code in that page:
Response.Clear()
Response.StatusCode = 503
Response.Flush()
I suppose I should mention that my local is a Windows 10 box, and the server VM is Windows Server 2016. Both are running IIS 10. The application is compiled with .NET Framework 4.6.
Here's the dev tools from my localhost:
Here's the dev tools from the server in azure:
Why the change? Anything I can do to stop this behavior?
So today I tried enabling Failed Request Tracing, but either something wasnt set up correctly, or the error was being handled elsewhere, and didnt result in any failed requests being logged.
Since I wasnt getting any failed requests logged, I opened up Process Monitor and could see that immediately after the call to my Health Probe page, I was getting a call to my custom HTTP Error page. That page must have been what was giving the 403 (dont know why, b/c that page works correctly for other HTTP Errors with a friendly error message and logging of the error to my custom error tracking solution).
I was going to change the Status Code to see if there was something special with the 503 that I was setting that was handled differently in IIS, but that got me thinking about how I was setting the status code...
In my research today, I saw this page https://www.leansentry.com/HowTo/AspNet-Response-Flush-Poor-Performance which cautions against using Response.Flush(). The code that I had implemented was in the Page_PreRender method, so there's not really a need to Flush there anyway.
I removed the Response.Flush and of course, my troubles went away.
The Health Probe page no longer triggers an Error from the Azure VM, and therefore, the status code that I get in my client browser is the 503 that I set in code.
So I guess this case is closed. I will need to figure out why the HTTP Error page was throwing a 403 instead of returning the friendly error message, but that should be easy enough...

Random 500 errors on IIS

I have been working on an application that provides some web services to a client. The MVC application is built on .Net 4.5 framework. Everything worked fine until we looked at the response statistics our client had generated, where we could see we weren’t responding 100%. The statistics showed response drop to 90%-95% every other day.
Inspecting the logs
The first thing I did was to check our application log where I couldn’t find any exceptions logged. We log all (unhandled) exceptions in our application, which would normally lead to an error HTTP status code, so finding no such exception made me think that the request has not reached the application at all. The next step was to check the IIS access logs and there I could not find any 500 errors. I was under the impression that something is going on with the network which is causing 500's.
Upon further investigation, I realized those are being generated by IIS server. I found this by setting up Failed Request Tracing on IIS and after a while I found following error logged:
ModuleName - ManagedPipelineHandler Notification -
EXECUTE_REQUEST_HANDLER HttpStatus - 500 HttpReason - Error Retrieving
Data HttpSubStatus - 0 ErrorCode -The operation completed
successfully. (0x0)
I've looked at various stackoverflow posts but nothing really helped me. I guess it is because of no of requests we make per minute around 200 requests per minute). But I get response for 90-95% requests.
Attached detailed error log here
I figured out what the error is. .Net servers don't receive these requests in the first place, these are getting lost in the network. There is an oracle gateway which is buggy and killing few requests.

IIS7 .NET (2.0, 4.0) completely hosed with a Bad Request (Error Code 400) error

All of a sudden all of my websites on my server return 400 Bad Request Error. I don't have a clue what happened. App Pools are running in Classic pipeline mode (4.0, 2.0), doesn't matter.
Every URL that I type comes back as 400 Bad Request. Real URLs, even fake URLs that don't exist (which should come back as 404) all are 400.
http://mywebsite.com/AFile.aspx
http://mywebsite.com/AFolder/AnotherFile.aspx
http://mywebsite.com/Bfolder/YetAnotherSillyPage.aspx
http://mywebsite.com/A_stupid_URL_that_does_not_even_exist_fjfjffjfj.aspx
Everything 400 Bad Request. Totally screwed up my ASP.NET. Where should I begin to look? Machine.config? Web.config?
UPDATE:
After trying a million different settings, I finally set the App Pool to Integrated and set the Identity to LocalSystem and all of a sudden it works.
Bad Request usually is HTTP.sys stopping the request due to something really bad (like invalid URLs, or something like that).
You probably should look at HTTP.sys logs (Not IIS) at:
C:\Windows\System32\LogFiles\HTTPERR
Also, maybe something got broken in the http.sys configuration so try running:
netsh http show servicestate
And see if for your web site it has the correct bindings, for example it could be that the bindings are only listening on only specific IP Addresses and yet its coming from another one, or similar problem but with Host Name, etc.
Finally you might want to run:
C:\Windows\System32\inetsrv\appcmd list sites
And see if the bindings and status makes sense.
Have you tried some mixture of re-installing (or uninstall/install) asp.net using the aspnet_regiis.exe utility? That's fixed strange IIS/ASP.NET server issues for me in the past.
Have you looked in the event log for any error messages or further clues?

Cannot get ASP.Net to serve any pages under IIS6

I am trying to set up another instance of a live website for a customer to evalulate, however i am unable to get the server to serve up any ASP.NET pages at all.
I know this is normally a bit of a noob question, but i have set up these servers a hundred times and know all the usual gotchas, i have done all of the following to no avail, and for my example i have created a simple test page that writes out hello world, and i'm still unable to get anything to serve..
This is windows server 2003 R2 SPII
I have registered ASP.NET using aspnet_regiis.exe -i
I have enabled the web service extensions
I have created it as a virtual directory, and created the application
I have set the version of ASP.NET for my virtual directory to use
I have even created a new App Pool and given it administrator permissions.
I have run Auth Diag From Microsoft, i get and error from the authentication check, but it is blank
I have given full control to the everyone group for the folder
I have tried creating a new website with a different port, same problem
In fiddler i get the following repsonse when loading an asp.net page :
HTTP/1.1 504 Fiddler - Receive Failure
Content-Type: text/html
Connection: close
Timestamp: 09:43:01:0634
ReadResponse() failed: The server did not return a response for this request.
Looking at the IIS logs, i dont see any entries for any of the ASP.NET requests unless i turn on windows authentication, then i see
2011-04-12 08:13:23 W3SVC1 10.4.3.16 GET /test/Test.aspx - 80 - 10.2.16.17 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+Trident/4.0;+GTB6.6;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729;+InfoPath.2;+.NET4.0C;+.NET4.0E) - 401 2 2148074254
2011-04-12 08:13:26 W3SVC1 10.4.3.16 GET /test/Test.aspx - 80 - 10.2.16.17 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+Trident/4.0;+GTB6.6;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729;+InfoPath.2;+.NET4.0C;+.NET4.0E) - 401 1 0
HTML Pages serve up just fine, i'm stumped and about to get the server re-built as i have wasted long enough on this..
Any ideas :( ?
I ended up removing IIS and re-installign it, set the site back up and it worked fine...
Have you checked the windows event log for information that may lead to what is causing this?
You could also try removing the application role and adding it again encase there was an issue when originally setting it up.

Unauthorized error when surfing to files

My IIS is configured to use WindowsAuthentication.
When I surf to the file:
I can see the file perfectly but when i'm checking with charles (http debugger) I see the following result.
alt text http://img155.imageshack.us/img155/6428/capturea.jpg
The problem is that when a browser does this, it will retry (apperantly up to 3 times) but when .NET (spring.net) tries this, it's crashes after the first attempt saying that I'm unauthorized.
Does anyone has a solution for this? I've been struggeling with this problem for weeks now.
I see this is normal. You may learn more about the conversation between client and server from this KB article,
http://support.microsoft.com/kb/264921
Then you will know why those 401 messages were there.
Regards,

Resources