Restrict user if user directly types url of any page

  • Thread starter Thread starter Jaydeep
  • Start date Start date
J

Jaydeep

Hi,
I want to restrict any user if he types url directly in the browser
without logging to my site. Like for example user should not see any listing
page of my web site by typing url http://localhost/customerList.aspx or
something like that, instead he should first login and then access this
page. How to achieve this functionality.
In classical ASP we used to include a common file which checks if cookie is
set or not or using HTTP_REFERRER server variable. How to include such file
in asp.net page ?

Thanks
 
Create a class that inherits System.Web.UI.Page, and put your code into that
class. Override the Base class's OnInit() Method in your derived class, and
put the code that checks the Session in there. Then, for your web pages,
rather than inheriting System.Web.UI.Page, inherit that page class. This
will add the functionality you're desiring to every Page, transparently.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
ASP.Net provides an authentication system in the web.config file. You can
specify for an entire directory (including its subdirectories) that only
authenticated users are allowed to view pages, and if a user is not
authenticated they will be redirected to a login form and then automatically
redirected to the original page they requested after a successful login.

Google ASP.Net authentication for some articles.

If you need to check individual pages (i.e. not an entire directory) you
will need to test pages manually.

Colin
 
Back
Top