Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am using Asp.net C# . I have many pages in my website but for example i have two page like :

http://www.codeproject.com/Login.aspx

second page

http://www.codeproject.com/Welcome.aspx

now problem is that when i write on browser http://www.codeproject.com/Welcome.aspx it directly open welcome page . what i want is if somebody try to open directly WELCOME page it redirect to lOGIN page

is short what i mean is First Login then welcome Page.

Please help me ................
Posted
Comments
Herman<T>.Instance 29-Aug-14 5:31am    
Check for valid username and password in Session object. If not, then Redirect to Login page.

Read and see this example. You have sample download here.

http://aspsnippets.com/Articles/Simple-User-Login-Form-example-in-ASPNet.aspx[^]

This Link has small Example.Very simple one

http://vsc.edu.in/blog/?p=237[^]
 
Share this answer
 
v2
Comments
Member 11014751 29-Aug-14 6:41am    
Thank You So Much.... :)
this link helped me

http://aspsnippets.com/Articles/Simple-User-Login-Form-example-in-ASPNet.aspx[^]
First make a Login Page

After successful login on button click store user id or user name in session . and chk that session at welcome Page load. If session exist then welcome page load otherwise it will redirect to login page..
And try to make your all web form using master page and on master page chk session. it will work for all web page inherit from master page..
Go for it..
you will get success.

Thanx
Md Tarique zafar
 
Share this answer
 
Comments
Sajid227 1-Sep-14 6:28am    
bro i have done this,and this is working fine on each page,my requirement is ahead of this. i want after doing this user will only see that page and enter the data in that form which is allowed to him from the database table,where i store all pages name and role Id against each page,hope you got point?/
What you want to use is called FormsAuthentication. http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication(v=vs.110).aspx[^]

With very little code you can make this happen. Essentially change web.config to use FormsAuthentication. This will tell ASP.Net to redirect any unauthenticated requests to your LoginPage. Then in your LoginPage after you have validated the user you write a few lines of code so that ASP.Net knows they are authenticated and then will let them through.

There are many samples online if you just search for FormsAuthentication and C#.
 
Share this answer
 
Comments
Sajid227 1-Sep-14 6:28am    
bro i have done this,and this is working fine on each page,my requirement is ahead of this. i want after doing this user will only see that page and enter the data in that form which is allowed to him from the database table,where i store all pages name and role Id against each page,hope you got point?/
ZurdoDev 1-Sep-14 8:25am    
Write some code that only allows them to get to that page. That will have to be custom or you can use the Location tag in your web.config.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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