asp.netweb-applicationsvisual-web-developer-2010

How to get requesting url when user is redirected to login page by web.config in asp.net


My web application immediately redirects users to a login page via web.config. How can I get the url that requested my page? I tried using the Request paramaters in Page_Load of the Login.aspx page but that didn't work.


Solution

  • I found the answer to what I was looking for by using UrlReferrer. See below.

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Request.UrlReferrer.ToString <> "" Then
            Session("PageUrl") = Request.UrlReferrer.ToString
        End If
     End Sub