Store Url, which user tried to Open before Login


Friday, August 21, 2009

First let me explain you the condition in which you can use this code.

Follow this steps
1.if you copy and paste some internal link to browers address bar.
And if that internal link required login authentication.

2.So the page will redirect you to login page and what our code will here is it will copy your first internal link ,which you were trying to open.

3.Now if you provide login details then our code will redirect to your internal link,which you have provided.

Please find below code in ASP.NET
------------------------------------------------
On click event
---------------
If Session("MemberID") = Nothing Then
Session("URL") = Request.Url.AbsoluteUri
Response.Redirect(Application("LinkURL") & "auction/login.aspx")
End If
Session.Remove("URL")

On login page
--------------
If Session("URL") <> Nothing Then
Response.Redirect(Session("URL"))
End If


Please find below code in C#
------------------------------------------------
On click event
---------------
if (Session["UserID"] == null)
{
Session["URL"] = Request.Url.AbsoluteUri;
Response.Redirect("login.aspx");
}
Session.Remove("URL");

On login page
--------------
if (Session["URL"] != null )
{
string redir = (string)Session["URL"];
Response.Redirect(redir);
}

For More details contact,
Rajesh Singh
Asp.Net Developer
Indianic infotech ltd (India)
rajesh@indianic.com

No comments :