开发者

Catch Unauthorized exception

I am connectin开发者_Go百科g to a webservice in my project by entereing user credentials(user name and password) i need to catch a unauthorized exception when the user enter invalid username/password. How can i do that


Are you attempting to catch an exception before calling the webservice?

try
{
    result = Service.GetResult(param1, param2);
}
catch(System.Net.WebException ex)
{
    Logger.WriteError("Error calling Webservice: ", ex.ToString());
}

WebException will catch server return codes as errors I believe, such as HTTP status 404: Not Found etc.


Is your web service SOAP? Are you using WCF on on the service side? If so, take a look at a Specifying and Handling Faults

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜