Asp.net HttpContext.Current.Response.Redirect正在尝试将用户发送到错误的位置
我有一段代码,在用户会话超时时将其重定向到页面:Asp.net HttpContext.Current.Response.Redirect正在尝试将用户发送到错误的位置,asp.net,iis,Asp.net,Iis,我有一段代码,在用户会话超时时将其重定向到页面: void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started string szCookieHeader = HttpContext.Current.Request.Headers["Cookie"]; if ((null != szCookieHeader) && (szC
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
string szCookieHeader = HttpContext.Current.Request.Headers["Cookie"];
if ((null != szCookieHeader) && (szCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
{
HttpContext.Current.Response.Redirect("SessionTimeout.aspx");
}
}
问题是IIS找不到SessionTimeout.aspx,因为它的位置不正确:
The file '/site/site/site/site/site/site/Site/SessionTimeout.aspx' does not exist.
随着时间的推移,添加了越来越多的“/site/”级别。我可以通过创建“../site/site/…”树并在每个树中放置SessionTimeout.aspx来抑制此问题,但这显然不是真正的解决方案
有人知道发生了什么吗?你试过使用~
HttpContext.Current.Response.Redirect("~/SessionTimeout.aspx");
这将在运行时通过您站点的完整url解决。您是否尝试使用~
HttpContext.Current.Response.Redirect("~/SessionTimeout.aspx");
这将在运行时使用站点的完整url解决。您的重定向是相对于当前页面的。将~/添加到url,使其查看站点的根目录 您的重定向应为:
HttpContext.Current.Response.Redirect("~/SessionTimeout.aspx");
您的重定向是相对于当前页面的。将~/添加到url,使其查看站点的根目录 您的重定向应为:
HttpContext.Current.Response.Redirect("~/SessionTimeout.aspx");