问题描述
我的asp.net c#网站有一个有趣的问题。问题只出现在我上传解决方案的时候,它在我在本地机器上运行时工作正常。
基本上,我有一个正常的登录页面通过文本框输入用户名和密码,将其与数据库匹配,有效时,我设置了一些会话变量
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
(Session["user_in"])
并将用户导航到default.aspx页面。
关于此default.aspx页面
and navigate user to default.aspx page.
On this default.aspx page under
page_load
事件,我有以下代码
event, I have following code
if (!IsPostBack)
{
if ((Session["user_in"] != "Y"))
{
Response.Redirect("~/Login.aspx");
}
}
在这个default.aspx页面上,我正在读取db并写入数据库。
但是在几次回发之后烦恼地,我退出了
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_load事件中的if条件下,这意味着它找不到
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
(Session["user_in"])
。
只有当我将解决方案上传到服务器时才会发生这种情况,本地机器不会那样做。
任何想法,请帮忙吗?
.
This only happens when i upload solution to the server, local machine doesn''t behave that way.
Any ideas, help please?
推荐答案
这篇关于ASP.NET C#:我在几次回发后失去了会话值!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!