Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2005 C# ASP.NET
Hi I am using C#, ASP.NET, VS2005. How can I prevent users from directly accessing a webpage? i.e. when a user enters - "www.google.com/thispage" the users is directed back to "www.google.com". The users can only access "www.google.com/thispage" via a link on "www.google.com". Thanks! Anyhelp is appreciated.
 
EDIT: I want to access a user go through the "front door"(www.google.com) and not by entering manually (www.google.com/thispage). Only by clicking a link/button on (www.google.com) then it will direct the user to (www.google.com/thispage).
Posted 29-Oct-12 19:34pm
Edited 29-Oct-12 22:32pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

put Response.Redirect("youpageurl"); in page load event.
Like
Protected Void thispage_load(object sender, eventArgs e)
{
     Response.Redirect("www.google.com");
}
  Permalink  
v4
Comments
AshishChaudha at 30-Oct-12 1:33am
   
Please elaborate your question more. There is insufficient information.
Member 9473758 at 30-Oct-12 2:06am
   
thanks for replying but what you given will redirect even if I access from anywhere right? I want to access a user go thru the "front door"(www.google.com) and not by entering manually (www.google.com/thispage). Only by clicking a link/button on (www.google.com) then it will direct the user to (www.google.com/thispage).
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

If you use Solution 1 you would never access that page. It will always redirect to www.google.com. You have to detect if user is trying access it directly. You can add QueryString(www.google.com/thispage?LinkClicked=Yes) or use Session.
 
If Request.QueryString("LinkClicked") != 'Yes'
{
Response.Redirect("www.google.com");
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Kornfeld Eliyahu Peter 265
1 Sergey Alexandrovich Kryukov 202
2 George Jonsson 185
3 King Fisher 185
4 CPallini 155
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 30 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100