Executing a validating query before loading a page

  • Thread starter Patrick Olurotimi Ige
  • 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?
 
O

Ollie Riches

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
 
I

IPGrunt

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top