今天在C#中要用到WebService ,报了请求因 HTTP 状态 401 失败: Unauthorized 的问题.
解决如下:
MakerContact.MakerContact wsMakeContact = new ModelNotice.MakerContact.MakerContact();
wsMakeContact.Url = ConfigurationManager.AppSettings["MakerContact"];
wsMakeContact.Credentials = System.Net.CredentialCache.DefaultCredentials; ---增加这句即解决问题