Click here to Skip to main content
11,718,016 members (84,630 online)
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 18:34pm
Edited 29-Oct-12 21: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 OriginalGriff 215
1 F-ES Sitecore 210
2 Maciej Los 140
3 Jochen Arndt 120
4 Andy Lanng 115
0 Sergey Alexandrovich Kryukov 1,649
1 OriginalGriff 535
2 Maciej Los 529
3 Richard MacCutchan 440
4 CHill60 415


Advertise | Privacy | Mobile
Web02 | 2.8.150901.1 | Last Updated 30 Oct 2012
Copyright © CodeProject, 1999-2015
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