Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
How to validate user is authenticated or not whenever he hit URL in the browser.
eg.
"http://localhost:52466/AdminWebsite/result.pdf"
if the user is authenticated then he should able to download the pdf file , if not redirect to Login page
Posted

While logging in use a key/flag to set the user logged in and use the key whenever he access the URL.or keep a session while user log in and check whether the session has the value or not.

Regards,
Hsakarp
 
Share this answer
 
Comments
[no name] 14-Nov-13 4:17am    
If the requested URL is http://localhost:52466/AdminWebsite/result.pdf then where to check the formauthentication or Session value.
hsakarp 14-Nov-13 5:15am    
Please find the below link..
http://stackoverflow.com/questions/15662543/check-session-in-every-page . It might help you
You may use FormAuthentication of Asp.Net.

It is the easiest way to authenticate the user.


---Chetan Patel
 
Share this answer
 
Comments
[no name] 14-Nov-13 4:17am    
But If the requested URL is http://localhost:52466/AdminWebsite/result.pdf which is not a aspx page then where to check the formauthentication or Session value.
Chetan Patel 16-Sep-14 2:35am    
Use HTTPHandler to validate the user. where you can write the pdf file as response for valid users and also you can pass message for invalid user's. as you can set the type of HTTP response.
You just need to add one Handler class to handle the request. then configure it to web.config ex://

<httphandlers>
<add type="<namespace>.<classname>,<Assemblyname>" path="*.pdf" verb="GET">

I am not Sure but you can pass some unique value for authenticated user in query string
while click button

and check the value of query string when page is load
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900