Executing a validating query before loading a page

  • Thread starter Thread starter Patrick Olurotimi Ige
  • Start date Start date
P

Patrick Olurotimi Ige

Is it possible to execute a query or do some validation before loading a
page..
I have a survey page and i want to validate users before loading the
page.
I have done it in the page_load.
But the problem i have is that if the user gets the URL and directly
paste it to the browser the USER still sees the page.
Is there a way how to check the user in the DB before loading the page
(I mean just by pasting the URL to the browser or just by clicking the
IE browser?
 
simple answer would be no....

why can't you attempt to validate the user and if they don't have the
credentials then redirect then to another page.

HTH

Ollie Riches
 
Is it possible to execute a query or do some validation before loading a
page..
I have a survey page and i want to validate users before loading the
page.
I have done it in the page_load.
But the problem i have is that if the user gets the URL and directly
paste it to the browser the USER still sees the page.
Is there a way how to check the user in the DB before loading the page
(I mean just by pasting the URL to the browser or just by clicking the
IE browser?


Yes, you use dotnet's authentication and authorization features.

You need a statement like this in your Web.config:

<system.web>
<authentication mode="Forms">
<forms name="LoginForm" loginUrl="Login.aspx" />
</authentication>
</system.web>

and another to setup authorization:

<location path="YourFile.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>


the deny users=? means that only authenticated users have access to the
file. Anonymous users will be redirected to your login page.

-- ipgrunt
 
Back
Top