What is so special about Page_Load?

We set session variables in Page_Load and then immediately redirected to another page before Page_Load completed.

When we got to the new page, the new page didn't see the session vars we set.

Is there something about Page_Load() where certain functionality is not available, such as session vars etc? Anything else that is tricky or unique about Page_Load()?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

can I see your code before comment
no, you can easily set session in page_load event and access it in any other pages inside the application

example code:

Main page
protected void Page_Load(object sender, EventArgs e)
            if (!IsPostBack)
                Session.Add("somename", "newpageasavalue");
                Response.Redirect("about.aspx", false);

Open in new window

 protected void Page_Load(object sender, EventArgs e)
            string NameSessionValue = string.Empty;
            if (Session["somename"] != null)
                NameSessionValue = Convert.ToString(Session["somename"]);
                // You can get the value in NameSessionValue string

Open in new window

Note : i think you well know about the session timeout, if you not, once the session is timeout, Session["somename"] will be destroyed, you cant access it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rascalAuthor Commented:
I noticed your code has a "return" statement after the redirect. My code did not. I assumed that the redirect preluded the need for the return, but is it possible the lack of a return (or in my case an exit sub statement since I'm in VB) was the culprit?
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

the return is not mandatory here

I recommand doing it witht he following lines


Open in new window

Try Server.Transfer instead of Response.Redirect
rascalAuthor Commented:
Thank you all for the helpful responses.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.