how can I use the connectionStrings defined in web.config ?
<connectionStrings>
<add name="projetosConn" connectionString="Data Source=sqlexpress;Initial Catalog=dbxxxx;Persist Security Info=True;User ID=sa;Password=xxxx" providerName="System.Data.SqlClient"/>
</connectionStrings>
and not :
string strConnection = "server=MCN-C2B848F240D\\SQLSERVER2005;database=Data;uid=sa;pwd=wintellect;";
Thanks for the article very helpful..
However I have a question.. I am in VS2010 and used the default ASP solution that adds the login pages... it also adds a login link at the top of the master page.. to bring you to the login page.. once you have logged in you end up back at the main page but the login link is still there instead of the welcome <username> and logout options.. how do I update that main page to show that someone is logged in... there is so little documentation on these default solutions that come bundled with VS... thanks for your help...
The means of programmer and developer is to show the hard work in an easy way and you have done it :0
nice one
FM
Former memberPosted Oct 27, 2009, 2:49 AM
Hi its just another feather in ur article's cap ; U r getting better with each passing article
OverviewLogin Controls in ASP.NET 3.5
The Login control provides the user interface to log
a user into a web site. The Login
control uses the Membership service to authenticate the user in your membership
system. The default Membership service from your configuration file will be
used automatically, however you can also set the Membership provider that you
would like used as a property on the control.
ASP.NET MEMBERSHIP
ASP.NET membership gives you a built-in way to validate and store user
credentials. ASP.NET membership therefore helps you manage user authentication
in your Web sites. You can use ASP.NET membership with ASP.NET Forms
authentication or with the ASP.NET login controls to create a complete system
for authenticating users.
ASP.NET membership supports facilities for:
Creating new users and passwords.
Storing membership information (user names,
passwords, and supporting data) in Microsoft SQL Server, Active Directory, or
an alternative data store.
Authenticating users who visit your site. You
can authenticate users programmatically, or you can use the ASP.NET login
controls to create a complete authentication system that requires little or no
code.
Managing passwords, which includes creating,
changing, and resetting them . Depending on membership options you choose, the
membership system can also provide an automated password-reset system that
takes a user-supplied question and response.
Exposing a unique identification for
authenticated users that you can use in your own applications and that also
integrates with the ASP.NET personalization and role-management (authorization)
systems.
Specifying a custom membership provider, which
allows you to substitute your own code to manage membership and maintain
membership data in a custom data store
The
Login Control consists of:
Username
Label and Textbox: Collects
the string used to identify the user in the membership system.
Password
Label and Textbox: Collects
the password for the specified user. The textbox text is always obscured.
LoginButton:
The
button to submit the users request for authentication.
RememberMe:
Configurable
to display a checkbox giving the user the option to store a persistent cookie
on the user's machine.
Title
and Instruction: Text
to orient and guide the user through the process.
Links:
Configurable
links to help, password recovery and user registration information.
Validators:
Required
field Validators for the username and password textboxes.
Figure 1.New tab for login
Login
controls in ASP.NET 3.5
There are the following login controls in ASP.NET 3.5.
Login
LoginView
PasswordRecovery
LoginStatus
LoginName
ChangeUserWizard
ChangePassword
1. Login
control
Login
control provides the server side functionality that is useful and does not
warrant adaptation. So, the goal of the Login control's adapter is to improve
the markup used in the form's presentation without touching the serverside
functionality.
The
Login control presents a simple HTML form for gathering user credentials. When
submitted, the web server's Membership Provider determines if the credentials
are valid correct and valid.
The
LoginView control automatically detects a user's authentication status
and role and matches that information to appropriate template of
information to display to that user.
The
LoginView control consists of a collection of templates that can be
associated with an authentication status or one or more role groups.
It
supports a collection of templates associated with different user
roles. Since a user can be associated with multiple roles and a
template can be associated with multiple roles it is important to
understand how the template is matched to the user's role.
3. PasswordRecovery
The
PasswordRecovery control provides the functionality to retrieve or
reset a user's password based on their user name. The information is
then emailed to the user. The control does not support displaying the password to the user in their web browser.
It
may be possible for the email containing the user's password to be
intercepted by hackers and thus compromise the users account.
The PasswordRecovery control uses the Membership service retrieve or reset the user's password.
if
((UserName == Dr["UserName"].ToString())
& (Password == Dr["Password"].ToString()))
{
boolReturnValue = true;
}
Dr.Close();
return
boolReturnValue;
}
return
boolReturnValue;
}
}
Login control is having a property called FailureText where you can write
your own message.
Figure 4. Custom Error Message
Once you have passed the correct login credential then you will be redirected
to the home page using the DestinationPageUrl property. DestinationPageUrl is
the property of login control which is used to redirect the user to desination
page after a successful login. If incorrect login credential it will show the
message like "Your login attempt was not successful. Please try
again". This is a custom message specified by the user through the
FailureText property.
Figure 5. Login Error
About inbuilt validation:- Login control is having a inbuilt validation
feature which is available as a property for programmer. When you will
drag-drop the control at design time you will see that the username and
password textboxes are marked with star (*) sign which means these fields are
required fields.
Figure 6. Validation
If you
insert correct usename, password then redirect your page whereever you
want or you can show message in ErrorLabel like this:
Ronaldo DantasPosted Oct 30, 2011, 9:12 AM
how can I use the connectionStrings defined in web.config ? <connectionStrings> <add name="projetosConn" connectionString="Data Source=sqlexpress;Initial Catalog=dbxxxx;Persist Security Info=True;User ID=sa;Password=xxxx" providerName="System.Data.SqlClient"/> </connectionStrings> and not : string strConnection = "server=MCN-C2B848F240D\\SQLSERVER2005;database=Data;uid=sa;pwd=wintellect;";
xuan anh dinhPosted Apr 13, 2011, 10:51 PM
Thanks for shared,It's very useful for me.
KenPosted Oct 4, 2010, 10:46 AM
Thanks for the article very helpful.. However I have a question.. I am in VS2010 and used the default ASP solution that adds the login pages... it also adds a login link at the top of the master page.. to bring you to the login page.. once you have logged in you end up back at the main page but the login link is still there instead of the welcome <username> and logout options.. how do I update that main page to show that someone is logged in... there is so little documentation on these default solutions that come bundled with VS... thanks for your help...
sac mPosted Mar 30, 2010, 5:20 AM
hi , this very useful article thanks sac
afzal khanPosted Mar 23, 2010, 2:34 AM
how to apply css in asp.net buildin login control
Nikhil KumarPosted Jan 10, 2010, 8:32 AM
The means of programmer and developer is to show the hard work in an easy way and you have done it :0 nice one
Former memberPosted Oct 27, 2009, 2:49 AM
Hi its just another feather in ur article's cap ; U r getting better with each passing article