I need to create an authentication webpage. In this web the users are saved in a propietary sql database. Is it possible to customize the websecurity helper or develop a custom authentication in webpages and razor, similarly as it's used in ASP.NET webforms?
It will give you an overview of the SimpleMembership, you could just add the membership
tables to your database and then add the connectionstring to the
WebSecurity.InitializeDatabaseFile
Regards
Jeremy
If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
That way future readers will know which post solved your issue.
Regards
Jeremy
If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
That way future readers will know which post solved your issue.
Hi jvilaro, if you are currently using the membership and role providers with asp.net webforms you should be able to do the same with webmatrix web pages. The web pages framework uses forms authentication just like web forms does as far as I can tell and
so should be able to support almost any authentication scheme that web forms does barring the use of the web form controls.
Regards
Jeremy
If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
That way future readers will know which post solved your issue.
Marked as answer by Dino He - MSFT on Feb 21, 2012 02:16 AM
Good to see you got it working. Thanks for the update.
Regards
Jeremy
If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
That way future readers will know which post solved your issue.
jvilaro
Member
18 Points
5 Posts
Custom authentication in WebMatrix
Feb 14, 2012 08:04 AM|LINK
I need to create an authentication webpage. In this web the users are saved in a propietary sql database. Is it possible to customize the websecurity helper or develop a custom authentication in webpages and razor, similarly as it's used in ASP.NET webforms?
Thank you in advance.
login
jeremyh
Star
8173 Points
1477 Posts
Re: Custom authentication in WebMatrix
Feb 14, 2012 12:01 PM|LINK
Take a look at
http://blog.osbornm.com/archive/2010/07/21/using-simplemembership-with-asp.net-webpages.aspx
It will give you an overview of the SimpleMembership, you could just add the membership
tables to your database and then add the connectionstring to the WebSecurity.InitializeDatabaseFile
Jeremy
If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
That way future readers will know which post solved your issue.
jvilaro
Member
18 Points
5 Posts
Re: Custom authentication in WebMatrix
Feb 14, 2012 02:05 PM|LINK
Thank you for your answer jeremyh but it's not exactly what I need. I already have a users table in my own database and I can't add membership tables.
In ASP.NET i can customize Login1_Authenticate method with my own code. Is possible to do something similar with WebMatrix?
Thank you again.
jeremyh
Star
8173 Points
1477 Posts
Re: Custom authentication in WebMatrix
Feb 14, 2012 02:56 PM|LINK
Is the user data that you have from the asp.net Memebership provider? If so you could define that in your web.config
and take a look at http://msdn.microsoft.com/en-us/library/webmatrix.webdata.extendedmembershipprovider(v=vs.99).aspx
But if the user data is from another source then I think you will have to be think along the lines of a custom provider.
You can disable the simplemembership provider with
Jeremy
If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
That way future readers will know which post solved your issue.
beetledev
Member
750 Points
173 Posts
Re: Custom authentication in WebMatrix
Feb 14, 2012 03:54 PM|LINK
Hi jvilaro, if you are currently using the membership and role providers with asp.net webforms you should be able to do the same with webmatrix web pages. The web pages framework uses forms authentication just like web forms does as far as I can tell and so should be able to support almost any authentication scheme that web forms does barring the use of the web form controls.
jvilaro
Member
18 Points
5 Posts
Re: Custom authentication in WebMatrix
Feb 15, 2012 07:45 AM|LINK
Can you tell me where i can find any example of developing a custom provider? Any reference?
Thanks jeremy and beetledev
jeremyh
Star
8173 Points
1477 Posts
Re: Custom authentication in WebMatrix
Feb 15, 2012 07:53 AM|LINK
The only one I have bookmarked is http://msdn.microsoft.com/en-us/library/aa479048.aspx
Good luck
Jeremy
If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
That way future readers will know which post solved your issue.
jvilaro
Member
18 Points
5 Posts
Re: Custom authentication in WebMatrix
Feb 15, 2012 09:37 AM|LINK
Thank you for all jeremyh
jvilaro
Member
18 Points
5 Posts
Re: Custom authentication in WebMatrix
Feb 15, 2012 11:21 AM|LINK
After some chances I found the solution.
In web.config must activate forms authentication
@using System.Web.Security; @{ Layout = "~/_SiteLayout.cshtml"; // Login if (IsPost) { if (userExist(Request.Form["username"], Request.Form["password"])) { FormsAuthentication.RedirectFromLoginPage(Request.Form["username"], false); } } } <section id="login"> <article class="splash"> <form method="post" action=""> <div class="indented"> <h1>Portal web móvil de Mentor</h1> <input type="text" id="username" name="username" placeholder="Usuario" /> <input type="password" id="password" name="password" placeholder="Contraseña" /> <input type="submit" value="Iniciar sesión" title="Iniciar sesión" class="button big" /> <div class="copyright">2012 - Summar</div> </div> </form> </article> </section>jeremyh
Star
8173 Points
1477 Posts
Re: Custom authentication in WebMatrix
Feb 15, 2012 11:29 AM|LINK
Good to see you got it working. Thanks for the update.
Jeremy
If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
That way future readers will know which post solved your issue.