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

  • Home
  • SEARCH
  • 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 977549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:55:13+00:00 2026-05-16T03:55:13+00:00

in my pageload i have got the session[name] When i use this code to

  • 0

in my pageload i have got the session[“name”]

When i use this code to save:

Stream stream = null;
request = (HttpWebRequest)WebRequest.Create(url);
response = (HttpWebResponse)request.GetResponse();

When it comes to this line:

response = (HttpWebResponse)request.GetResponse();

it again move on to the pageload and that time the session is null. how??? how to maintain the session in the same page. why it is cleared when this line encounters…

  • 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-05-16T03:55:14+00:00Added an answer on May 16, 2026 at 3:55 am

    The reason that sessions don’t persist with HttpWebResponse is because by default, HttpWebResponse will not handle cookies for you. ASP.NET uses a cookie to identify which session belongs to a user.

    Thankfully, there’s a helper class called CookieContainer that can help you with this. Create a CookieContainer and attach it to your web request – on subsequent requests, you will need to attach the cookie container, or the cookies within it to the request again to persist session:

    CookieContainer cookieJar = new CookieContainer();
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com");
    request.CookieContainer = cookieJar;
    
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    
    // on a second request, you can use the cookieJar container to pass the session cookie.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got this event in my page aspx.cs: public void deleteBtn_Click(object sender, CommandEventArgs
I've got this textBox which triggers off an ajax request using jQuery: <asp:TextBox ID=postcodeTextBox
I got this code in my Master page : <script type=text/javascript> $(#<%=hfJavaScriptDetected.ClientID %>).val('yes'); </script>
i have got below code which is working fine: public abstract class Beverage {
Have you got another idea to get this list of data? I would like
i have a dialog box that opens on pageload for a site. script type=text/javascript>
I have the below column on my table what gets binded on pageload, the
I have a masterpage setup, with a pageLoad in the topmost masterpage, which calls
I have code in my Page_load method that can take up to a few
I have this: protected void Page_Load(object sender, EventArgs e) { nome_Txt.Text = Profile.dados_pessoais.nome; }

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.