Login page

Posted by Gopal.net under ASP.NET on 7/15/2009 | Views : 1228 | Status : [Member] | Replies : 5
hi,

I Created one web application,Contains Different aspx pages.

If i Gave http//: localhost/Default2.aspx in Browser. It automatically opens Default2.aspx page.

But i want if any URL it may be Default1,Default2.aspx......................

I want to go to Home page(or)login page first for all URL's

sample code required.......

thanks & regards,
gopal.net




Responses

Posted by: perfectchourasia-9163 on: 11/17/2011 [Member] Starter | Points: 25

Up
0
Down

in buttonclick code write this

Session.Abandon();
Session.Clear();
response.redirect("login.aspx");

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Gopal.net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 7/15/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Morning Gopal.net

If i undestand you correctly you have page1 and page2 and you dont want your users to access page2 without accessing page1. if that is the case you have to use Sessions to do this.

in page1 you can create a session variable that will tell you that it has been accessed and clear it when the second page is closed. And in the second page check if the session is null if its null send the user to page1

like this

Session[Accesed] = "Accessed";


First in your page2 page load event , check if the session created in page1 session if its Null like this

if(Session[Accesed] == null)
{
response.redirect("page1.aspx",false");
}


Thank you for posting at dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Gopal.net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vsureshvarma on: 7/16/2009 [Member] Starter

Up
0
Down
in ur web.config file

<authentication mode="forms">
<forms name="mywebsite" path="/" loginUrl="UrLoginPage" defaultUrl="Ur LoginPage" Protection="All">
</forms>
</authentication>

Gopal.net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bravi on: 7/16/2009 [Member] Starter

Up
0
Down

You need to provid authentication in web.config like below

<authentication mode="Forms">
<forms loginUrl="login.aspx" protection="All" name="somename"/>
</authentication>

<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>

I hope it will slove your problem..

Gopal.net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Poster on: 7/17/2009 [Member] Starter

Up
0
Down
I suggest you to read articles about Forms Authentication and you will get better idea on how to do this.

http://www.dotnetfunda.com/articles/article114.aspx
http://www.dotnetfunda.com/articles/article423-forms-authentication.aspx

Advance:
http://www.dotnetfunda.com/articles/article141.aspx

Thanks

Gopal.net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response