我有一个相对简单的ASP.Net应用程序,我已经建立了一些简单的安全。用户使用用户名和密码登录,然后根据数据库进行检查。如果成功,我将它们的用户对象存储在名为“UserID”的会话变量中,并将它们重定向到同一页面,只是这次他们没有看到登录面板。 (MMM可能只是将其隐藏动态,但我认为这将导致反正页面重新加载)失去的ASP会话变量,所以我认为
在我的Default.aspx页面,我有以下代码:
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserID"] == null)
{
LoginPanel.Visible = true;
}
}
protected void btnLogin_Click(object sender, EventArgs e)
{
Security security = new Security();
Session["UserID"] = security.LoginUser(txtUsername.Text, txt2Password.Value);
if (Session["UserID"] != null)
{
Response.Redirect("~/default.aspx");
}
}
权,到目前为止,一切顺利。此外值得一提的是母版页:
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserID"] == null)
{
//Check that we are not already on the default.aspx page.
//Don't want to cause infinite redirect here
if (!Request.Path.ToLower().Contains("default.aspx"))
{
Page.Response.Redirect("~/Default.aspx");
}
}
else
{
//Otherwise we get the UserObject from the session and display menu items //based on the role. Nothing fancy.
}
}
//Bad naming. This a logout link on the master...
protected void Unnamed1_Click(object sender, EventArgs e)
{
Session["UserID"] = null;
Page.Response.Redirect("~/Default.aspx");
}
现在,所有这些都可以在我的本地IIS实例上完美工作。只要我部署到我们的生产服务器,我点击我的菜单项之一,然后说找到Search.aspx,它会将我带回到Default.aspx页面,其中LoginPanel可见?这也是在Firefox中。在IE中,我可以点击Search.aspx菜单链接,它会将我带到页面,但单击我的GridView中的编辑链接也会将LoginPanel显示返回到Default.aspx页面。
我根本不是ASP.net的专家,而且我很聪明。所以请尽可能少用行话等方式来回答问题,然后发布文档和msdn等链接,以便我不只是解决这个问题,而是真正理解为什么这会给我做恶梦。
TIA
是一个Web农场在生产服务器? – Chandu 2011-03-22 13:32:17
您是否将数据库移至服务器?它是否具有与本地副本相同的信息? – 2011-03-22 13:38:20
不确定服务器是否在服务器场中。数据库没有问题向上移动。 – n4rzul 2011-03-23 11:09:44