How do you authenticate users with Forms Authentication usingan existing Database in MVC4

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="line-height:115%; font-family:Segoe UI,sans-serif; font-size:20.5pt Authenticating Users with Forms Authentication
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Segoe UI,sans-serif; font-size:10pt I currently have an existing database created by the ASP.NET SQL Server Setup Wizard. It was created for a MVC 3 application. I am creating
a new application in MVC 4 and would like to take advantage of it, but it is not working. I set up the connection string and other information required, but when I click on the login button (of the new App) I get an error in the following function :<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt <span>

<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt public<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt override<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt void<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt OnActionExecuting(<span style="background:white; color:#2b91af; font-family:Consolas; font-size:9.5pt ActionExecutingContext<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt
filterContext)
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:black; font-family:Consolas; font-size:9.5pt <span>
{
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:black; font-family:Consolas; font-size:9.5pt <span>
<span style="background:white; color:green; font-family:Consolas; font-size:9.5pt // Ensure ASP.NET Simple Membership is initialized only once per app start
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:black; font-family:Consolas; font-size:9.5pt <span>
<span style="background:white; color:#2b91af; font-family:Consolas; font-size:9.5pt LazyInitializer<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt .EnsureInitialized(<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt ref<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt
_initializer, <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt ref<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt _isInitialized,
<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt ref<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt _initializerLock);
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:black; font-family:Consolas; font-size:9.5pt <span>
}
<span style="line-height:115%; font-family:Segoe UI,sans-serif; font-size:10pt I am not sure why!!!
<span style="line-height:115%; font-family:Segoe UI,sans-serif; font-size:10pt Bellow you will find some of the code in the web config, but not my connection string

<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt membership<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt providers<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt clear<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt />
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt add<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt name<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt AspNetSqlMembershipProvider<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt type<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt System.Web.Security.SqlMembershipProvider<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt connectionStringName<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt KaneSecurity_Conn<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt enablePasswordRetrieval<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt false<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt enablePasswordReset<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt true<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt requiresQuestionAndAnswer<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt false<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt requiresUniqueEmail<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt false<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt maxInvalidPasswordAttempts<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt 5<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt minRequiredPasswordLength<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt 6<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt minRequiredNonalphanumericCharacters<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt 0<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt passwordAttemptWindow<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt 10<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt applicationName<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt customerportal<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
/>
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
</<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt providers<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
</<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt membership<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt profile<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt providers<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt clear<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt />
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt add<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt name<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt AspNetSqlProfileProvider<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt type<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt System.Web.Profile.SqlProfileProvider<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt connectionStringName<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt KaneSecurity_Conn<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt applicationName<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt customerportal<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
/>
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
</<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt providers<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
</<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt profile<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<!--<span style="background:white; color:green; font-family:Consolas; font-size:9.5pt <roleManager defaultProvider="AspNetWindowsTokenRoleProvider" /><span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt -->
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt roleManager<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt enabled<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt true<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt providers<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt clear<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt />
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt add<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt connectionStringName<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt KaneSecurity_Conn<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt applicationName<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt customerportal<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt name<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt AspNetSqlRoleProvider<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt type<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt System.Web.Security.SqlRoleProvider<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
/>
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt add<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt applicationName<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt customerportal<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt name<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt AspNetWindowsTokenRoleProvider<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt type<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt System.Web.Security.WindowsTokenRoleProvider<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
/>
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
</<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt providers<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<span style="background:white; color:blue; line-height:115%; font-family:Consolas; font-size:9.5pt <span>
</<span style="background:white; color:#a31515; line-height:115%; font-family:Consolas; font-size:9.5pt roleManager<span style="background:white; color:blue; line-height:115%; font-family:Consolas; font-size:9.5pt >
<span style="line-height:115%; font-family:Consolas; font-size:9.5pt Thank you in advance
<br/>
<br/>
<br/>
<br/>

View the full article
 
Back
Top