Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 28th, 2004, 02:23 AM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with using WebRequest class in C#

hi all,
i'm generating a webrequest afte a user submits his form.
but i'm getting the following error:
The underlying connection was closed: The remote name could not be resolved
can anyone help me out please?
here is the code i'm using:

        string result = "";
    WebRequest req = WebRequest.Create("Url here");
        //i'm getting error from the following line
    WebResponse webresponse = req.GetResponse();
    Stream ReceiveStream = webresponse.GetResponseStream();

    Byte[] read = new Byte[512];
    int bytes = ReceiveStream.Read(read, 0, 512);
    while (bytes > 0)
    {
        Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
        result = result + encode.GetString(read, 0, bytes);
        bytes = ReceiveStream.Read(read, 0, 512);
    }
        // the response contains name value pairs separated by commas
    string[] response = result.Split(',');
    string key;
    string valuePart;
    NameValueCollection nr = new NameValueCollection();
    int i = 0;
    foreach (string xx in response)
    {
        i = xx.IndexOf("=");
        key = xx.Substring(0,i);
        valuePart = xx.Substring(i + 1);
        nr.Add(key,valuePart);
    }




Similar Threads
Thread Thread Starter Forum Replies Last Post
WebRequest/WebResponse form submit problem. HELP! MAtkins ASP.NET 1.0 and 1.1 Professional 2 December 23rd, 2010 12:28 AM
Error with Webrequest mike_remember ASP.NET 1.0 and 1.1 Professional 5 October 17th, 2006 08:01 AM
WebRequest Response Error hpatel_it ASP.NET 2.0 Basics 0 October 17th, 2006 06:50 AM
Experts?? Problem w/ Webrequest MAtkins ASP.NET 1.0 and 1.1 Professional 2 April 9th, 2006 10:21 PM
WebRequest Authentication venterjo ASP.NET 1.0 and 1.1 Professional 0 November 2nd, 2005 08:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.