Webservice method to call a url

↘锁芯ラ 提交于 2019-12-06 09:49:19

The Response.Redirect method sends a Status Code 300 to the browser which directs the user to a new page. What you want to do is create a WebRequest and parse the response:

string url = string.Format("www.insuranceini.com/insurance.asp?fileno1={0}", txtfileno1);
WebRequest request = HttpWebRequest.Create(url);
using(WebResponse response = request.GetResponse())
{
    using(StreamReader reader = new StreamReader(response.GetResponseStream()))
    {
        string urlText = reader.ReadToEnd();
        //Do whatever you need to do
    }
}

EDIT: I wrapped the WebResponse and StreamReader objects in using statements so they are disposed of properly once you're finished with them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!