How to prevent project from running by simply copying the url of tha specific page [Resolved]

Posted by Sharmagoldi781 under .NET Framework on 12/4/2013 | Points: 10 | Views : 1843 | Status : [Member] | Replies : 4
How to prevent project from running by simply copying the url of the specific page while a user in logged in and when that user logs out pasting that url and getting access to that page and and entire project...please specify in detail




Responses

Posted by: Kmandapalli on: 12/4/2013 [Member] Silver | Points: 50

Up
0
Down

Resolved
Hi,

When the user logs in, get his username and save it Session variable.
Once he gets logged in u will be redirecting him to another page.
So, in that page check whether Session["Username"] is null or not, if the Username is null, then redirect him to the LogIn page or else if the Session["Username"] contains data then redirect him to that particular user.....

Mark as answer if satisfied..........

Regards,
Shree M.

Kavya Shree Mandapalli

Sharmagoldi781, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 12/4/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Write code in your logout button:
Session.Clear();
Session.Abandon();

Sharmagoldi781, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 12/4/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Simply write:-

protected void Page_Init(object Sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
}

Sharmagoldi781, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 12/4/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Alternatively you can check

if(Request.UrlReferrer==null)
resoponse.redirect("logout.aspx");

Request.UrlReferrer gives us the previous page url,from where it is redirected.

Sharmagoldi781, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response