Logging In Users Programmatically in Asp.Net

InfoPath alternatives for form designing SharePoint

In this post we will discuss on how we can Logging in users programmatically in Asp.Net. Also you can check out my previous posts on:

– ModalPopupExtender background css not coming when showing from code behind in asp.net

– Show confirmation dialogbox using JavaScript in Asp.Net

– Data access block of Microsoft enterprise library 6.0 using stored procedure

You can use pre-built mechanics of the Login control or you can also perform this task programmatically using the Membership class. To validate credentials that you receive, you use the ValidateUser() method of this class. The ValidateUser() method takes a single signature:

Membership.ValidateUser(username As String, password As String)

Validating a user’s credentials programmatically

In VB.net:

If Membership.ValidateUser(TextBox1.Text, TextBox2.Text) Then

FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, False)

Else

Label1.Text = “You are not registered with the site.”

End If

In C#.net:

if (Membership.ValidateUser(TextBox1.Text, TextBox2.Text)

{

FormsAuthentication.RedirectFromLoginPage(TextBox1.Text.ToString(), false);

}

else

{

Label1.Text = “You are not registered with the site.”;

}

The ValidateUser() method returns a Boolean value of True if the user credentials pass the test and False if they do not.

you can see that end users whose credentials are verified as correct are redirected from the login page using the RedirectFromLoginPage() method. This method takes the username and a Boolean value that specifies whether the credentials are persisted through a cookie setting.

Similar SharePoint 2013 Tutorials


About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply