仅关闭customErrors的Web服务 [英] Turn off customErrors for web service only

查看:156
本文介绍了仅关闭customErrors的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.NET 2.0网络应用程序包括一个Web服务,它会引发各种异常以及自定义错误消息(例如您无权访问此项目等)。这些显示在屏幕上,在ASP.NET AJAX回调处理程序中。



其余的应用程序由一些自定义错误页面覆盖,以通常的方式在Web中指定.config。

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

我的问题是如果我在web.config中启用了customErrors,我丢失了从Web服务 - 而不是被替换为



处理请求时出错 - 这对我或用户来说都不是很有用。



有没有办法关闭Web服务的自定义错误?

解决方案

将您的Web服务放入单独的目录,并将其他web.config文件放在此目录中。每个目录可以拥有自己的web.config,其中包含此目录的设置(以及此目录中的目录)。


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?

解决方案

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).

这篇关于仅关闭customErrors的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆