C# 如果用户访问了';飞溅/着陆';页
我有一个非常简单的C#在用户进入C# 如果用户访问了';飞溅/着陆';页,c#,asp.net,C#,Asp.net,我有一个非常简单的C#在用户进入/default.aspx主页时将其重定向到初始页面: if (Session["homepageHoarding"] == null) { Response.Redirect("/homepage-hoardings/limited-offer.aspx"); } 在“启动”页面上:/homepage boardings/limited offer.aspx,有一个返回“正常”主页的链接,当然是:/default.aspx 但它再次重定向,认为会话不存
/default.aspx
主页时将其重定向到初始页面:
if (Session["homepageHoarding"] == null)
{
Response.Redirect("/homepage-hoardings/limited-offer.aspx");
}
在“启动”页面上:/homepage boardings/limited offer.aspx
,有一个返回“正常”主页的链接,当然是:/default.aspx
但它再次重定向,认为会话不存在,实际上它不存在
我怎样才能让他们看到启动页面后记得他们已经看到了呢?我不能使用global,因为我糟糕的web主机不允许使用它:-(
非常感谢:-)如评论中所述,使用cookies:
bool userVisited = false;
HttpCookie cookie = Request.Cookies["MyCookie"];
if (cookie == null)
{
cookie = new HttpCookie("MyCookie");
cookie.Values.Add("userVisitedSplash", true);
cookie.Expires = DateTime.Now.AddDays(30); //<-- Sets the expiration date
cookie.HttpOnly = true;
this.Page.Response.AppendCookie(cookie);
} else{
userVisited = cookie.Values["userVisitedSplash"]
}
if(userVisited){
Response.Redirect("~/Default.aspx");
} else{
Response.Redirect("/homepage-hoardings/limited-offer.aspx");
}
bool uservisted=false;
HttpCookie cookie=Request.Cookies[“mycokie”];
if(cookie==null)
{
cookie=新的HttpCookie(“MyCookie”);
cookie.Values.Add(“userVisitedSplash”,true);
cookie.Expires=DateTime.Now.AddDays(30);//如评论中所述,使用cookie:
bool userVisited = false;
HttpCookie cookie = Request.Cookies["MyCookie"];
if (cookie == null)
{
cookie = new HttpCookie("MyCookie");
cookie.Values.Add("userVisitedSplash", true);
cookie.Expires = DateTime.Now.AddDays(30); //<-- Sets the expiration date
cookie.HttpOnly = true;
this.Page.Response.AppendCookie(cookie);
} else{
userVisited = cookie.Values["userVisitedSplash"]
}
if(userVisited){
Response.Redirect("~/Default.aspx");
} else{
Response.Redirect("/homepage-hoardings/limited-offer.aspx");
}
bool uservisted=false;
HttpCookie cookie=Request.Cookies[“mycokie”];
if(cookie==null)
{
cookie=新的HttpCookie(“MyCookie”);
cookie.Values.Add(“userVisitedSplash”,true);
cookie.Expires=DateTime.Now.AddDays(30);//虽然在这种情况下有点太多,但您可以尝试设置cookie关于添加'Session[“splashVisited”]=true'?您尝试过什么?目前您的问题归结为我的网站表现与预期一致,但我希望有所不同。
。附带说明:是否真的有必要重定向用户?从用户体验的角度来看,这似乎有点烦人。常规的网站内弹出窗口不够醒目吗?您在哪里设置会话的值[“HomePagePagePaging”]?似乎总是空的。避免完全使用会话。它不会扩展,并且意味着您正在服务器上保持状态。使用cookie来指示用户已执行此操作。尽管在这种情况下设置cookie有点太多,但您可以尝试设置cookie关于添加“会话[”splashVisited“]=true'?您尝试过什么?目前您的问题归结为我的网站表现与预期一致,但我希望有所不同。
。旁注:是否真的有必要重定向用户?从用户体验的角度来看,这似乎有点烦人。常规的网站内弹出窗口不够醒目吗?您在哪里设置会话[”的值HomePagePagePaging“]?似乎总是空的。避免完全使用会话。它不会扩展,并且表示您在服务器上保持状态。使用cookie指示用户已执行此操作。