问题描述
在我的网站上,我从基类继承每个网页的类以检查会话超时
Hi,
In my website, I inherit each web page's class from a base class for checking session timeout
Partial Class Default
Inherits SessionManagement
.
.
End Class
SessionManagement类看起来像
SessionManagement class looks as
Imports Microsoft.VisualBasic
Public Class SessionManagement
Inherits System.Web.UI.Page
Public m_bIgnoreSessionTimeout As Boolean = False
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
Dim sPageName As String = String.Empty
Try
MyBase.OnInit(e)
If m_bIgnoreSessionTimeout = True Then
Exit Sub
End If
If Not Context.Session Is Nothing Then
If Session.IsNewSession = True Then
Dim sCookieHeader As String = Request.Headers("Cookie")
If IsNothing(sCookieHeader) = False Then
If sCookieHeader.IndexOf("ASP.NET_SessionId") > -1 Then
Session.Abandon()
Response.Redirect("~/SessionTimeout.htm", False)
HttpContext.Current.ApplicationInstance.CompleteRequest()
'End If
End If
End If
End If
Catch ex As Exception
Session.Abandon()
Response.Redirect("~/SessionTimeout.htm", False)
HttpContext.Current.ApplicationInstance.CompleteRequest()
End Try
End Sub
End Class
sessiontimeout.htm页面与default.aspx存在于同一文件夹中。
会话到期时或t imes out,默认页面试图转到sessiontimeout.htm但是给出错误400
我右键点击它并检查了网址,它显示了我
http://< webserver name => /MyWebSite/%2fMyWebSite%2fsessiontimeout.htm
我的问题是为什么它没有尝试重定向到路径为http://< webserver name => /MyWebSite/sessiontimeout.htm,而是通过附加< sitename> /sessiontimeout.htm来选择上面的路径基本网址?
谢谢
Vijay
The sessiontimeout.htm page exists in the same folder as of default.aspx.
When the session expires or times out, the default page tries to go to sessiontimeout.htm but gives error 400
I right clicked on it and checked the url, it showed me
http://<webserver name="">/MyWebSite/%2fMyWebSite%2fsessiontimeout.htm
My question is why it did not try to redirect to the path as http://<webserver name="">/MyWebSite/sessiontimeout.htm and instead chose the path above by appending <sitename>/sessiontimeout.htm to the base url?
Thanks
Vijay
推荐答案
Response.Redirect(ResolveURL("~/sessiontimeout.aspx"))
它应该解析浏览器的URL。否则,您可以使用 Server.Transfer
而不是 Response.Redirect
并将往返保存到客户端。
祝你好运!
It should resolve the url for the browser. You could otherwise use Server.Transfer
instead of Response.Redirect
and save the round trip to the client.
Good luck!
这篇关于response.redirect不会重定向到正确的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!