Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8965169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:45:23+00:00 2026-06-15T16:45:23+00:00

The following code hangs when I try to run it on .NET 3.5 (it

  • 0

The following code hangs when I try to run it on .NET 3.5 (it works when I set the project to .NET 4)

(I’ve waited like 2 minutes – It seems to freeze)

        HttpWebRequest l_oRequest;
        HttpWebResponse l_oResponse;

        if (m_bLoggedIn)
            return true;

        m_oSession = new SSessionIdentifier();
        m_oSession.Cookies = new CookieContainer();

        string l_sHost = "https://website.com";

        // Start the login sequence
        l_oRequest = GetNewRequest(l_sHost, "Login.aspx", m_oSession.Cookies);
        l_oRequest.Timeout = 5000;
        l_oRequest.ReadWriteTimeout = 5000;
        l_oRequest.Method = "POST";
        l_oRequest.Referer = "https://website.com";

        // Set form parameters
        string l_sFormParameters = "user=" + m_sUsername;

        // Convert them to the HTTP stream
        byte[] l_oRequestBuffer = UTF8Encoding.ASCII.GetBytes(l_sFormParameters);
        var l_oRequestStream = l_oRequest.GetRequestStream();
        l_oRequestStream.Write(l_oRequestBuffer, 0, l_oRequestBuffer.Length);

        // I'm setting this to false because otherwise i can't get the cookies i want. And I love them cookies!
        l_oRequest.AllowAutoRedirect = false;

        // Now start the redirection sequence until we get to what we want
        int l_iDTPos = -1;
        // This line hangs
        l_oResponse = (HttpWebResponse)l_oRequest.GetResponse();
        while (l_oResponse.StatusCode == HttpStatusCode.Found)
        {
                // Yada Yada

This is the GetNewRequest function:

    private HttpWebRequest GetNewRequest(string host, string targetUrl, CookieContainer a_oCookieJar)
    {
        HttpWebRequest l_oRequest = (HttpWebRequest)HttpWebRequest.Create(host + targetUrl);
        l_oRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2";
        l_oRequest.ContentType = "application/x-www-form-urlencoded";
        l_oRequest.AllowAutoRedirect = false;
        l_oRequest.CookieContainer = a_oCookieJar;

        return l_oRequest;
    }

I couldn’t find any change between 3.5 and 4 in the documentation. Has anyone ran into such a problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:45:24+00:00Added an answer on June 15, 2026 at 4:45 pm

    I was hitting this same issue where I was calling a RESTful service using HttpWebRequest and my code worked great in .Net 4+ and hung on the GetResponse() line in .Net 3.5, 3.0. 2.0. I ended up trying the sample code from this article:

    http://msdn.microsoft.com/en-us/library/debx8sh9.aspx

    and got it working in all versions of .Net. I’m guessing I wasn’t setting something correct or closing a resource, but for anyone else who hits this give the article a try.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code gives seg fault and some time stalls/hangs and never works. for(i=0;i<360;i++)
When I run the following code it basically works how I intend it to,
My code seems to compile okay, but when I try to run it, it
Got a problem with my add function to my database. The following code hangs
Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to
Following code gets executed whenever I want to persist any entity. Things seems to
Following code is a pretty simple and complete JQuery Dialog. Everything works. Problem is
We are using the following Apache Commons Net FTP code to connect to an
The following code works well 99% of the time. However, when I use it
I have the following code where I try to convert the string 03080000 into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.