c# - How do I get the URI that threw a WebException? -


I'm calling a method on a webservice and it's throwing a 403 forbidden WebException ...

< Blockquote>

System.Net.WebException: Request failed with HTTP status 403: is prohibited.

I got this error but I really want to enter the URI log message so it is easy to determine which web site is causing the problem.

Is there an easy way to remove URI from webexception? I have seen through the list of properties and I do not see anything that I will get.

You can access the Url property on your SOAP client proxy object ( SoapHttpClientProtocol type).

If you are calling two different web services, by one method in your code, just grab an attempt around web service calls and apply the appropriate custom exception Throw off the URL of the offending web service with the property.

Like something:

  string url = client.Url; Try {Client.MyWebServiceCall (); Url = client2.Url; Client2.MyWebServiceCall2 (); } Hold (Exception precedent) {New exception throw ("WebService call failed.URL:" + url + ", error:" + east. Message, east); }  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -