i want to know that from which pages my current page has been called in ASP.net
As for example
I want the track of page named "hero.aspx" and it has been called from "Zero.aspx" and "Zero.aspx" has been called from "one.aspx"
So i want output as whole page called hierarchy.
How can i get this i开发者_如何学编程n asp.net
you can use this:
HttpRequest.UrlReferrer
http://msdn.microsoft.com/en-us/library/system.web.httprequest.urlreferrer.aspx
You can get the referring page from
VB:
Request.ServerVariables("HTTP_REFERER")
C#
Request.ServerVariables["HTTP_REFERER"]
If you want the path I think you will have to save each page coming to it in session and then append each page to the list.
#Region "Properties"
Public Property prevPage() As String
Get
If Not ViewState("prevPage") Is Nothing Then
Return CType(ViewState("prevPage"), String)
Else
Return Nothing
End If
End Get
Set(ByVal Value As String)
ViewState("prevPage") = Value
End Set
End Property
#End Region
If Not IsPostBack Then
If Not Request.UrlReferrer Is Nothing Then
prevPage = Request.UrlReferrer.ToString
End If
End If
精彩评论