dannystommen
June 10th, 2009, 11:33 AM
I want to throw an 'nice' exception in asp.net
[WebMethod()]
public string testException(string key) {
if (key == "test"){
return "succeeds"
}
else{
throw new SoapException("Invalid key", SoapException.ClientFaultCode);
}
}
In client I recieve the a SoapException with message:
System.Web.Services.Protocols.SoapException: Invalid key
at MyProject.testException(String key) in ..myproject\my_service.asmx.cs:line 32
First of all, this doesn't look nice, and second, I don't want to show the stacktrace to the client.
I also use an 3th-party webservice. When an axception happens in this service, the message property of the SoapException is just the error message with out Exception type in the message and the stacktrace.
How to solve this?
[WebMethod()]
public string testException(string key) {
if (key == "test"){
return "succeeds"
}
else{
throw new SoapException("Invalid key", SoapException.ClientFaultCode);
}
}
In client I recieve the a SoapException with message:
System.Web.Services.Protocols.SoapException: Invalid key
at MyProject.testException(String key) in ..myproject\my_service.asmx.cs:line 32
First of all, this doesn't look nice, and second, I don't want to show the stacktrace to the client.
I also use an 3th-party webservice. When an axception happens in this service, the message property of the SoapException is just the error message with out Exception type in the message and the stacktrace.
How to solve this?