IIS 8.5: Detailed errors for remote calls - asp.net

I have a ASP.Net 5.2.3 WebAPI application running on a Windows Server 2012R2 with IIS 8.5.
When I make a local request that causes exceptions in the ASP.Net code, I get a nice, complete error message with stack traces. When I send the same request from another host, I only get a HTTP500 with body { "Message": "An error has occurred." }. I think this is the default behavior.
Now I want to enable these detailed error messages for remote requests, too. I searched around for a few hours already, and found these measures:
Edit Web.config
<system.web>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed" existingResponse="PassThrough" />
</system.webServer>
Enable 'Send errors to browser' in IIS Mangaer (IIS->ASP)
as described here: https://serverfault.com/questions/670853/iis-8-show-classic-asp-errors-in-browser
Enable "Detailed" IIS Error Page settings in IIS Manager (IIS->Error pages->500)
as described here: https://blogs.msdn.microsoft.com/rakkimk/2007/05/25/iis7-how-to-enable-the-detailed-error-messages-for-the-website-while-browsed-from-for-the-client-browsers
None of which seems to work, so I'm out of ideas by now.
Maybe it has to do with that my ASP.Net application is hosted in an existing IIS Site. I checked that the above modifications (step 2 & 3) are correctly applied on each level.

Give this a try...
To set the error policy in the application, modify the global Web API configuration:
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy
= IncludeErrorDetailPolicy.Always;
https://lostechies.com/jimmybogard/2012/04/18/custom-errors-and-error-detail-policy-in-asp-net-web-api/

Related

ASP.NET disable debug error messages on localhost

I have a project that is running a small node.js application as a reverse proxy. Some of the requests the reverse proxy receives are directed to IIS installed on the same machine, which naturally hit IIS over localhost / 127.0.0.1.
As a result, IIS automatically returns detailed error messages in the case of an error. Naturally, the proxy sends these to the user, which is not good because they contain more information than I want external users to see. I have tried to turn off the detailed error messages by explicitly setting compilation debug="false" in web.config, but since the requests come over the localhost, IIS seems determined to return detail debug error messages.
Is there a way to disable these debug error messages from being returned even when the request is coming over localhost?
I am running Windows 2012 RS, IIS 8, .NET 4.6.
OK, I found what I needed to do to make sure that IIS never returns detailed error messages, local or not.
More details can be found here.
The short answer is: Launch IIS Manager, click on the website, under IIS go to Error Pages, right click on the pre-defined error message and select "Edit Feature Settings", and select "Custom error pages". Then define the page that you want displayed.
Alternatively, you can define your preferences in web.config under system.webServer with values such as those listed below. The "errorMode" defaults to "DetailedLocalOnly", which causes the issue I am trying to avoid. Setting to "Custom" resolves the issue.
<httpErrors errorMode="Custom">
<remove statusCode="401" subStatusCode="-1"/>
<error statusCode="401" prefixLanguageFilePath="" path="/errors/401.html" responseMode="ExecuteURL"/>
</httpErrors>

Server Error in '/admin' Application....An application error occurred on the server

I have 2 projects in my solution (ASP.NET MVC 5), one for the client and one for the admin. Both projects are running fine locally. But when I publish the admin project (which is located in the path: root/admin in my hosting) I'm getting the next error:
An application error occurred on the server. The current custom error
settings for this application prevent the details of the application
error from being viewed remotely (for security reasons). It could,
however, be viewed by browsers running on the local server machine.
Something to know, I have added:
<system.web>
<customErrors mode="Off"/>
</system.web>
But i don't see any specific error and also I have configured the virtual directory root/admin as an application in IIS.
I know this is a common error but I don't see any solution like this one: Server Error in '/' Application. ASP.NET
The entry "Data.Models.ApplicationDbContext" has already been added.
That along with the Source File being the web.config, I'd look to see if that ApplicationDbContext is in the web.config twice and causing an issue in loading the application.
In the error message above is this reference:
e:\Web\deliver4\admin\web.config line: 18
So, what are around line 18 in that web.config file?
I solved the problem with this https://stackoverflow.com/a/6679286/2958543
<remove name="Data.Models.ApplicationDbContext" />
after my connectionString.

How do I turn off friendly error messages in IIS Express running on Chrome?

I switch from Visual Studio 2013's Development Environment to IIS Express. My browser of choice is Chrome.
I used to get the standard ASP.net error page in D.E. but now I get a friendly error message page in IIS Express. How do I show detailed error messages in Chrome?
In case you're wondering, I know there's an error in my code. I did that on purpose to see how error message's display in IIS Express
How do I display detailed errors in Chrome?
Update: The error was caused by a malformed Web.Config. How do I set up IIS Express to display detailed Web.Config error message?
You need to set in the web.config file
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>

Full Trust doesn't seem to work with WebMatrix Web.config file

Well, I've been told by my host that I need to enable FullTrust in my webmatrix website because I keep getting an error. (BUT, I have used a different host, and everything on my site works perfectly with them without modification). Anyway, I used the code my host suppllies in their KB, but that just generates a different error. So I looked up full trust on google and used about 5 different code samples to enable full trust but they all generate errors! even the ones on MSDN. And googling "Full Trust WebMatrix" doesn't really bring anything helpful either.
How can I successfully add full trust to a web.config file that is made using WebMatrix?
Any help is greatly appreciated!
Thank you
One of about 20 different errors:
HTTP Error 500.19 - Internal Server
Error
The requested page cannot be accessed
because the related configuration data
for the page is invalid.
Detailed Error Information:
Module
IIS Web Core
Notification
Unknown
Handler
Not yet determined
Error Code
0x8007000d
Config Error
Config File
\?\C:\Users\Jason\Documents\My Web
Sites\OSF\web.config
Requested URL
http://localhost:40625/Default.cshtml
Physical Path
Logon Method
Not yet determined
Logon User
Not yet determined
Request Tracing Directory
C:\Users\Jason\Documents\IISExpress\TraceLogFiles\
Config Source: -1:
0:
More Information: This error occurs
when there is a problem reading the
configuration file for the Web server
or Web application. In some cases, the
event logs may contain more
information about what caused this
error.
If you see the text "There is a
duplicate
'system.web.extensions/scripting/scriptResourceHandler'
section defined", this error is
because you are running a .NET
Framework 3.5-based application in
.NET Framework 4. If you are running
WebMatrix, to resolve this problem, go
to the Settings node to set the .NET
Framework version to ".NET 2". You can
also remove the extra sections from
the web.config file. View more
information »
The web.config file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<securityPolicy>
<trust level="Full" />
</securityPolicy>
<defaultDocument>
<files>
<add value="Default.cshtml" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
securityPolicy or trust element in system.web element.
securityPolicy Element (ASP.NET Settings Schema)
trust Element (ASP.NET Settings Schema)

HTTP 500 Internal Error - IIS websites

I have installed SP 2010 in a Windows Server 2008 R2 loaded environment. I have been using VS 2010 for developing application pages for SP 2010.
I make use of wsp builder to package all my dlls, pages, scripts and images into a solution package and deploy it in the web applications.
Everything was working like a charm. I started enduring a torrid time when all of a sudden my web applications started popping up with 'HTTP 500 Internal Server Error'. This started happening after I made some drastic changes in my application pages and deployed it.
I tried creating new web applications but its not doing me any good. Any insights on what could be the source of this issue?
Regards,
Raghuraman.V
Fixed this problem by editing the Web.config and applicationhost.config.
C:\Users\\Documents\IISExpress\config or right click the IIS Express icon on the tray and view all application and click the desired website and then click the configuration file link.
Comment out
<error statusCode="500" prefixLanguageFilePath="%IIS_BIN%\custerr" path="500.htm" />
Set the parent node to <httpErrors errorMode="DetailedLocalOnly"
Set the httpErrors to Allow
<section name="httpErrors" overrideModeDefault="Allow" />
Change your web project web.config HttpErrors
<httpErrors errorMode="Custom" existingResponse="Auto">
That should fix it, its basically saying that "I dont want IIS Express to override the configuration of my site".
To resolve, you should first instruct IIS to display detailed error messages, instead of just "500".
Adjust your web.config file and set custom errors to off:
<customErrors mode="Off" />
(case-sensitive).
In addition, if you are using Internet Explorer, turn of the advanced option "Show friendly error messages".
To help others, here there is a guide that helped me to find what was wrong with my setup (credits to Rick Barber):
Working past 500
Load the site from a browser located on the same server. In IE you may need to turn off ‘show friendly http errors.’
Temporarily add the following within the appropriate tags in your web.config file:
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
</system.webServer>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" />
</system.web>
</configuration>
Open up IIS Manager and try to open up some of the different features by double clicking on the icon. If there is an error in the web.config file and it can’t even parse it, sometimes you will get a helpful error.
Look in Windows Event Viewer. Sometimes you can find the detailed error logged in there, particularly Application Event Viewer.
Setup Failed Request Tracing. This is especially helpful if it is an intermittent 500 error.
Look through the web log files. This is especially helpful for an intermittent 500 error. You can often parse the log files to see if there is a trend with a specific page that is throwing a 500 error.

Resources