Click here to Skip to main content
15,848,319 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have created a web application using ASP.NET C#, SQLServer 2005.

In this, the first page is login page... if user has the username and password, he can login.

I have many Inner pages.

User can open the application, copy and paste the Inner pages link.

If user pastes the inner pages link... it should redirect to login page.

Do not open the application without login.

But here, I can access the application, after pasting the inner pages link.

But I don't need this, if user pastes the inner page link in browser, it should redirect to login page.

Please help. Thank you!
Updated 27-Oct-23 5:29am
Osman24 27-May-13 6:41am    
how did you redirect to inner pages. There is no difference with Response.Redirect and coping url. Am I wrong ? Did you mean anything else?
ShivKrSingh 27-May-13 6:46am    
he wants to check if user is logged in then only other page should display. other wise it should be redirected to login page.

you can use session for this. When your logged out you need to clear all session values.
if you using master page then you can write this code to master page load event.

if (Convert.ToString(Session["UserName"]).Length <= 0)

here default page is yours login page.

and on logout you should need to write.

Share this answer
You might want to search ASP.Net Authorization[^] & Authentication[^]. That will be a more solid solution.

There is also an article in CP: ASP.NET authentication and authorization[^]

Good luck,
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