开发者

WinForm Security Context

I have written a WinForms app that uploads addresses from a spreadsheet, and geocodes them using an external geocoding service. This all works fine on my local machine, but the time has come for it to be installed on other peoples computers for testing. The app no longer works now though, generating the below error:

 System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.

Having read a lot and chatted breifly to our network guys, it seems i need to establish the Security Context for the users account and work with this to corre开发者_JAVA技巧ct the error.

Has anyone got any pointers about how I should be going about this?

Thanks in advance!

C


It depends on how your uploading the data. If your using a http request (as it looks like you are) it will look something like;

  HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://test.example.com/");
  req.Method = "POST";
  req.ContentType = "text/xml";

  req.Credentials = new NetworkCredential("TESTACCOUNT", "P@ssword");

  StreamWriter writer = new StreamWriter(req.GetRequestStream());
  writer.Write(input);
  writer.Close();
  var rsp = req.GetResponse().GetResponseStream();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜