本文介绍了会话帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在myproject/MasterPages中有一个母版页文件
和我的内容页面位于myproject/pages
登录页面位于myproject/default.aspx
我正在应用用户必须具有登录才能查看页面的功能
我正在母版页的加载事件中执行此操作,例如==>
I have a master page file located in myproject/MasterPages
and my content pages are located in myproject/pages
The login page is located on myproject/default.aspx
I am applying the functionality that a user should have to login for viewing a page
i m doing this in masterpage''s load event like this ==>
protected void Page_Load(object sender, EventArgs e)
{
if (Session["user"] == "" && !SessionProperties.IsUser)
{
Response.Redirect("~/Default.aspx");
}
else
Response.Redirect("~/Pages/Default.aspx");
}
我想知道如何编写First Response.Redirect,以便将用户重定向到登录页面?
I want to know how can i Write First Response.Redirect so that it redirects user to Login page?
推荐答案
protected void Page_Load(object sender, EventArgs e)
{
if (Session["user"] != null && SessionProperties.IsUser)
Response.Redirect("~/Pages/Default.aspx");
}
并将此代码写入安全页面的母版页面
And write this code to the master pages of the secure pages
protected void Page_Load(object sender, EventArgs e)
{
if (Session["user"] == null || !SessionProperties.IsUser)
{
Response.Redirect("~/Default.aspx");
}
}
这篇关于会话帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!