如何编程要求在ASP.NET网址? [英] How do I programmatically request a URL in ASP.NET?

查看:107
本文介绍了如何编程要求在ASP.NET网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想服务器以编程方式调用一个URL(一个ASHX页)和存储响应为字符串。使用的HttpWebRequest似乎并不像它会正常工作,因为我不想重定向客户那里。

I would like the server to call a URL (an ashx page) programmatically and store the response as a string. Using HttpWebRequest doesn't seem like it will work properly because I do not want to redirect the client there.

感谢。

推荐答案

如果你想调用另一个页面,并获得响应返回字符串,可以使用 Web客户端

If you want to call another page and get the response back as string, you can use WebClient class.

var myWebClient = new WebClient();
string resultStr = myWebClient.DownloadString("http://www.google.com");

这篇关于如何编程要求在ASP.NET网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆