我想通过类在后台运行ASP.NET网页 [英] I want to run ASP.NET web page in background through class
本文介绍了我想通过类在后台运行ASP.NET网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨专家,
我使用wcf服务开发了我的项目。我希望代码在运行服务时在后台运行网页。请帮帮我,
提前谢谢
我尝试过:
我试过以下代码
HttpWebRequest webRequestObject = null;
StreamReader sr = null;
HttpWebResponse webResponseObject = null;
webRequestObject =(HttpWebRequest)WebRequest.Create(http:// localhost:27746 / Textpage?Email =+ Email +);
webRequestObject.Method =POST;
webRequestObject。 ContentType =application / x-www-form-urlencoded;
Stream newStream = webRequestObject.GetRequestStream();
但我无法知道网页运行与否。
解决方案
签出以下代码。在执行结束时,您将获得htmlValue变量中的网页响应
var request = WebRequest.Create(http://google.com);
var response = request.GetResponse();
using(Stream responseStream = response.GetResponseStream())
{
StreamReader reader = new StreamReader(responseStream);
string htmlValue = reader.ReadToEnd();
}
Hi Experts,
I developed my project using wcf services. I want code for run a web page in background at the time of running the service. Please help me ,
Thanks in advance
What I have tried:
I tried with below code
HttpWebRequest webRequestObject = null; StreamReader sr = null; HttpWebResponse webResponseObject = null; webRequestObject = (HttpWebRequest)WebRequest.Create("http://localhost:27746/Textpage?Email="+Email+"); webRequestObject.Method = "POST"; webRequestObject.ContentType = "application/x-www-form-urlencoded"; Stream newStream = webRequestObject.GetRequestStream();
But i haven't able to know the webpage was run or not.
解决方案
Checkout below code. At the end of execution you will get web page response in htmlValue variable
var request = WebRequest.Create("http://google.com"); var response = request.GetResponse(); using (Stream responseStream = response.GetResponseStream()) { StreamReader reader = new StreamReader(responseStream); string htmlValue = reader.ReadToEnd(); }
这篇关于我想通过类在后台运行ASP.NET网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文