Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a funny issue with my asp.net c# website. The problem only comes when i upload the solution online, it just works fine when I am running on local machine.

Basically, i have a normal login page where I take username and password via text boxes, match it against the db and upon validity, I set up some session variables
SQL
(Session["user_in"])
and navigate user to default.aspx page.

On this default.aspx page under
page_load 
event, I have following code

C#
if (!IsPostBack)
        {
            if ((Session["user_in"] != "Y"))
            {
                Response.Redirect("~/Login.aspx");
            }
           
        }


And on this default.aspx page, I am reading from db and writing to db.

But annoyingly after a few postback, i get signed out to
Login.aspx
page.

And the only code on the page that does that is under if condition in page_load event, meaning that it cannot find the value of
SQL
(Session["user_in"])
.

This only happens when i upload solution to the server, local machine doesn't behave that way.

Any ideas, help please?
Posted

1 solution

A few things to look into:

1) Session Timeout - From your question, I am guessing this isn't a problem for you. Still just make sure you have required session timeout set in your web.config file.
2) Are you abandoning your session somewhere? Does this happen on a particular page or it happens randomly on any page?
3) Do you have a logging in place? What have you done to deal with unhandled exceptions? You have logs, you should check them out if there is something relevant. You should also check the event viewer on the server. It usually logs unhandled exceptions as well.

These are just a way to narrow down your problem. Start with them and let us know if you have any success.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900