Calling HttpWebRequest.GetResponse() hangs my program!

Discussion in 'ASP .Net' started by Mahernoz, Oct 17, 2007.

  1. Mahernoz

    Mahernoz Guest

    Hi Friends,

    I have this code in a C# console application which calls a URL on my
    website(Asp.net/C#) with Querystrings. (I have also tried without
    querystrings).

    The problem is my program gets hanged. Even no error message is
    displayed.

    HttpWebRequest req =
    (HttpWebRequest)WebRequest.Create(CaptureURLForScheduler +
    strQueryString);
    req.Method = "POST";

    ASCIIEncoding encoding = new ASCIIEncoding();
    byte[] byte1 = encoding.GetBytes(strQueryString);
    req.ContentLength = byte1.Length;

    //This line hangs my program
    HttpWebResponse res = (HttpWebResponse)req.GetResponse();
    //This line hangs my program

    Can you tell me what's going on and how can i fix this?

    Regards,
    Mahernoz
    Mahernoz, Oct 17, 2007
    #1
    1. Advertising

  2. See answer in the C# group. No need to cross-post, it just makes it harder
    for people to know which is the active thread.
    --
    Recursion: see Recursion
    site: http://www.eggheadcafe.com
    unBlog: http://petesbloggerama.blogspot.com
    BlogMetaFinder: http://www.blogmetafinder.com



    "Mahernoz" wrote:

    > Hi Friends,
    >
    > I have this code in a C# console application which calls a URL on my
    > website(Asp.net/C#) with Querystrings. (I have also tried without
    > querystrings).
    >
    > The problem is my program gets hanged. Even no error message is
    > displayed.
    >
    > HttpWebRequest req =
    > (HttpWebRequest)WebRequest.Create(CaptureURLForScheduler +
    > strQueryString);
    > req.Method = "POST";
    >
    > ASCIIEncoding encoding = new ASCIIEncoding();
    > byte[] byte1 = encoding.GetBytes(strQueryString);
    > req.ContentLength = byte1.Length;
    >
    > //This line hangs my program
    > HttpWebResponse res = (HttpWebResponse)req.GetResponse();
    > //This line hangs my program
    >
    > Can you tell me what's going on and how can i fix this?
    >
    > Regards,
    > Mahernoz
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Oct 17, 2007
    #2
    1. Advertising

  3. "Peter Bromberg [C# MVP]" <> wrote
    in message news:...
    > See answer in the C# group. No need to cross-post, it just makes it harder
    > for people to know which is the active thread.


    Did you mean multi-post? Cross posting is fine if it really is ambigous
    which group a question ought to be posted.


    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Oct 17, 2007
    #3
  4. Right. No need to split hairs, I am sure the OP got the picture if he / she
    posesses an above room-temperature IQ. :)
    --
    Recursion: see Recursion
    site: http://www.eggheadcafe.com
    unBlog: http://petesbloggerama.blogspot.com
    BlogMetaFinder: http://www.blogmetafinder.com



    "Anthony Jones" wrote:

    > "Peter Bromberg [C# MVP]" <> wrote
    > in message news:...
    > > See answer in the C# group. No need to cross-post, it just makes it harder
    > > for people to know which is the active thread.

    >
    > Did you mean multi-post? Cross posting is fine if it really is ambigous
    > which group a question ought to be posted.
    >
    >
    > --
    > Anthony Jones - MVP ASP/ASP.NET
    >
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Oct 17, 2007
    #4
  5. "Peter Bromberg [C# MVP]" <> wrote
    in message news:...
    > Right. No need to split hairs, I am sure the OP got the picture if he /

    she
    > posesses an above room-temperature IQ. :)


    Most people who multi-post have never heard the terms multi-post or
    cross-post.

    I therefore should have in fact been more explicit.

    Multi-post: To post the same question to various groups as individuals
    messages. Replies to these messages only appear in the group in which it
    was found.

    Cross-port: To post the same question to various groups by addressing a
    single message to multiple groups. By default when replying a newsreader
    will address the reply to all groups that the orignal message was posted to.
    Hence the reply will be seen in all groups not just the one it was found in.

    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Oct 19, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff B
    Replies:
    1
    Views:
    13,146
    Rick Strahl [MVP]
    Dec 20, 2003
  2. warlord
    Replies:
    12
    Views:
    10,501
    warlord
    Apr 21, 2004
  3. japslam japslam via DotNetMonster.com

    Please help !! Problem about HttpWebRequest - GetResponse()

    japslam japslam via DotNetMonster.com, Apr 22, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    10,925
    Bruce Barker
    Apr 22, 2005
  4. Steve Richter
    Replies:
    2
    Views:
    10,502
    Shane Thomas
    Apr 30, 2005
  5. GlennLanier
    Replies:
    2
    Views:
    21,263
    GlennLanier
    Jun 10, 2005
Loading...

Share This Page