Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off customErrors for web service only

My ASP.NET 2.0 web app includes a web service, which throws various exceptions along with custom error messages (e.g. "You do not have access to this item" etc.). These are shown on screen, in a ASP.NET AJAX callback handler.

The rest of the app is covered by some custom error pages, specified in the usual way in web.config.

<customErrors mode="RemoteOnly" defaultRedirect="Error.html">
      <error statusCode="404" redirect="NotFound.html" />
      <error statusCode="403" redirect="NoAccess.html" />
</customErrors>

My problem is if I have customErrors enabled in web.config, I lose my error messages returned from the web service - instead they are replaced with

"There was an error processing the request" - which isn't very useful for either me or the users.

Is there a way to turn off custom errors for just the web service?

like image 404
Phil Jenkins Avatar asked Jun 09 '09 09:06

Phil Jenkins


2 Answers

Put your web service into separate directory and put additional web.config file in this directory. Each directory can have it own web.config containing settings of this directory (and directories inside this directory).

like image 136
smok1 Avatar answered Sep 22 '22 18:09

smok1


Yes, the custom errors element

can be defined at any level in the application file hierarchy.

So provided your WebService is in a folder you can add a web.config for that folder and turn them off.

like image 29
Zhaph - Ben Duguid Avatar answered Sep 21 '22 18:09

Zhaph - Ben Duguid