我该如何进行身份验证的Web客户端请求? [英] How do I authenticate a WebClient request?
问题描述
我在我的网站使用Web客户端制作的网页的电话。我试图让网页放入PDF格式,所以我想获得一个字符串的重新呈现页面的presentation的结果。问题是,该请求未经过身份验证,因此所有我得到的是一个登录界面。我有UseDefaultCredentials资源发送至真,但我仍然得到同样的结果。下面是我的code的一部分:
Web客户端Web客户端=新的WebClient();
webClient.Encoding = Encoding.UTF8; webClient.UseDefaultCredentials = TRUE;
返回Encoding.UTF8.GetString(webClient.UploadValues(联系,POST,形式));
什么样的身份验证您使用的是?如果是窗体身份验证,然后在最好的,你必须找到.ASPXAUTH cookie,并通过它在 Web客户端
请求。
在最坏情况下,它不会工作。
I am making a call to a page on my site using webclient. I'm trying to get the result of the webpage put into a pdf so I am trying to get a string representation of the rendered page. The problem is that the request is not authenticated so all I get is a login screen. I have sent the UseDefaultCredentials property to true but I still get the same result. Below is a portion of my code:
WebClient webClient = new WebClient();
webClient.Encoding = Encoding.UTF8;
webClient.UseDefaultCredentials = true;
return Encoding.UTF8.GetString(webClient.UploadValues(link, "POST",form));
What kind of authentication are you using? If it's Forms authentication, then at best, you'll have to find the .ASPXAUTH cookie and pass it in the WebClient
request.
At worst, it won't work.
这篇关于我该如何进行身份验证的Web客户端请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!