Click here to Skip to main content
11,581,397 members (59,608 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 340
1 Sergey Alexandrovich Kryukov 155
2 virusstorm 114
3 Frankie-C 105
4 RyanDev 84
0 OriginalGriff 1,273
1 Sergey Alexandrovich Kryukov 895
2 Abhinav S 597
3 F-ES Sitecore 500
4 Suvendu Shekhar Giri 433


Advertise | Privacy | Mobile
Web03 | 2.8.150603.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