问题描述
我使用 System.Xml.XmlTextReader
来读取一个HTTP位置XML流。现在我需要支持从一个安全的HTTPS站点读取。我怎样才能通过提供用户凭据以某种方式做到这一点?
I am using System.Xml.XmlTextReader
to read xml stream from a http location. Now I need support to read from a secure https site. How can I do this by providing user credentials in some way?
推荐答案
查看MSDN上的说明文件的财产。它包含使用CredentialCache一个样本。
Check out the documentation at MSDN for the HttpWebRequest.Credentials property. It contains a sample using the CredentialCache.
这可能是你所需要的(在一个集成的安全方案),但你可能想读的的文档,如果你想提供一个用户名和密码字符串。还有
This may be what you need (in a integrated security scenario), but you might want to read the docs of NetworkCredential as well if you want to provide a username and password as strings.
一旦你的HttpWebRequest的工作,你只是说:
Once you have the HttpWebRequest working you just say:
XmlTextReader rd = new XmlTextReader(yourHttpWebResponse.GetResponseStream());
这篇关于如何加载使用XmlTextReader的HTTPS XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!