ASP.NET - membership provider mvc3 razor

Asked By rahul patil on 20-Jun-12 09:14 AM
Earn up to 20 extra points for answering this tough question.
an any one tell me how to implement custom membership provider in asp.net  MVC3 with razor view i just want to know in this way

        1)create ASP.net MVC3 application
       2)choose internet template and and Razor view
       3)Add Class  "CustomMembershipProvider " in Models folder ,extend MembershipProvider class ,generate the   code  for not implemented methods  ///here i want to know how to modify the code please provide code
    
       4)create table for storing users information like Name,Password ,Email in sql server
        5)modify web.confing to support CustomMembershipProvider

  ok i will know only above things what i do for rest of things


also i want that only registerd users can show the welcome page lator on i want roleprovider  so please provide me something so that i complete my work aslo provide detail guidance how to modify code i saw alot of links on google but not getting exact work  please if any one has working code send me thanks 

     
Jitendra Faye replied to rahul patil on 20-Jun-12 09:42 AM
There are some good links, which will help you to create custom membership provider-

http://www.codeproject.com/Articles/165159/Custom-Membership-Providers
http://www.codeproject.com/Articles/13032/Custom-MembershipProvider-and-RoleProvider-Impleme


http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx

http://www.shiningstar.net/ASPNet_Articles/CustomProvider/CustomProvider.aspx

Hope this will help you.
[)ia6l0 iii replied to rahul patil on 20-Jun-12 12:31 PM
You would be surprised to know that there is a solution in CodePlex, that I have used a while back, to get a full-fledged working sample solution that implements Custom Membership Provider. 

You can find the sample @ CodePlex in the following url. Note that this uses Razor model, and Entity framework.
http://custommemberprovider.codeplex.com/releases/view/84184 

For your followup question of how to enable custom providers in the configuration file, here are the steps. 
a) Add a configuration file for your application. Web.config, to be precise. 

b) Set up the default provider in the membership node. See below for sample. 
<membership defaultProvider="providername" />

c) Add the Custom member Provider in the membership's provider collection. 
<membership defaultProvider="provider name">
<providers>
<add name="provider name" type="type of the provider" connectionStringName="con.string.name"
enablePasswordReset="true"  maxInvalidPasswordAttempts="4" minRequiredNonalphanumericCharacters="0" 
passwordAttemptWindow="10" writeExceptionsToEventLog="false" applicationName="/"
/>
</providers>
</membership>

d) Add the Role Manager.
<roleManager defaultProvider="provider name">
<providers>
<add name="provider name" type="type of the provider" connectionStringName="con.string.name" applicationName="/" />
</providers>
</roleManager> 

Needless to say, your custom membership provider needs to implement the MembershipProvider class as shown in the example below. 

public class myOwnCustomProvider :MembershipProvider
{
    public override bool ValidateUser(string username, string password) 
    {
 
    //place all your logic here.
    }
}

Hope this helped.
Neha Garg replied to rahul patil on 21-Jun-12 05:20 AM

Hi


My suggestion is that ASP.NET authentication model is good for this purpose. ASP.NET supports a number of authentication models such as forms, windows, passport, etc.

 

See the article and step by step description with codes given on the below links:


http://www.brianlegg.com/post/2011/05/09/Implementing-your-own-RoleProvider-and-MembershipProvider-in-MVC-3.aspx


http://www.danharman.net/2011/06/23/asp-net-mvc-3-custom-membership-provider-with-repository-injection/

help
Hi All, I am in the process of creating an asp.net 2.0 application with c# with authentication piece. I was looking into different forums for last 5 times of password reset No Yes Can I add my own routines to custommembershipprovider in addition to override methods. I am going to write code for all routines (validateuser the need of using membershipprovider ? I appreciate your response. Thanks, Katta keywords: Visual Studio .NETexception, ASP.NET, routine, class, Password Reset description: Authentication decision for ASP.NET 2.0 application Hi All, I am in the process of creating an asp
i have to implement the custom membership provider please tell me ho w to do that i done upto create class CustomMembershipProvider extending Membershipprovider modify web.confing for using custommembership provider, create users table only that what site. Read more - -- -- -- -- -- -- http: / / programmers.stackexchange.com / questions / 110182 / implementing-your-own-membership-provider-in-asp-net-mvc http: / / stackoverflow.com / questions / 9263537 / sample-code-for-creating-custom-membership-provider keywords: SQL Server, Oracle, NET Framework, ASP.NET, class, database, membership information description: MVC3 i have to implement the custom membership provider please tell me ho w to do that i done upto create class CustomMembershipProvider exten
custom database for all of the user membership and rolls. How do you do this? ASP.NET Discussions SQL Express (1) Visual Studio (1) SqlMembershipProvider (1) Application (1) CustomMembershipProvider (1) Database (1) MembershipProvider (1) ViaAccess (1) I'm not a programmer, per se, in an art degree). However, over the past several years, I've become fairly proficient at ASP.net 1.1 development. I'm at the point where I know and understand enough to Recently, I tried taking a break from MOSS (shudder) and get up to speed on ASP.net 2.0 I immediately got completley and utterly stuck on the membership provider thing. All Application Configuration wizard. I can't tell if this is a failing of Visual Studio, ASP.net 2.0, or SQL Express. I have a hunch it's a bit of
ambitious to start with partial trust ;) 1. the <trust> level in web.config 2. public CustomMembershipProvider 3. it depends. . . compilation is different - but easy - pages / controls are compiled by demand (or http: / / msdn.microsoft.com / msdnmag / issues / 06 / 01 / ExtremeASPNET / - -- -- Dominick Baier (http: / / www.leastprivilege.com) ASP.NET Security Discussions CustomMembershipProvider (1) App_Code (1) ExtremeASPNET (1) PermCalc (1) SDK (1) Provider (1) Compiled (1) Leastprivilege (1 ambitious to start with partial trust ;) 1. the trust level in web.config 2. public CustomMembershipProvider 3. it depends. . . compil
is as follows: Line 29: <providers> Line 30: <clear / > Line 31: <add name = "AspNetCustomMembershipProvider" type = "CustomMembershipProvider.CustomMembershipProvider" / > Line 32: < / providers> Line 33: < / membership> I've discovered that overriding the standard MembershipProvider requires and that one possible fix is to add the following to the top of my CustomMembershipProvider: [assembly: AllowPartiallyTrustedCallersAttribute()] However, when I do this, although the solution builds okay, I get the ideas to point me in the right direction would be very much appreciated. Thanks! Matt ASP.NET Security Discussions AllowPartiallyTrustedCallersAttribute (1) IIS (1) Database (1) Parser (1) Config (1) Hi, first of
tables for a datatype of uniqueidentifier and relationships already created) or should i make a custommembershipprovider and change the type of the tables sqlregtool creates (time consuming)? Note: All my tables key into your existing table so you can have a foreign key relationship to the ASP.NET users table. In this manner all you need to do is 2 simple things: 1 clustered index on either. See this good article about membership and sql server http: / / www.asp.net / learn / security / tutorial-04-cs.aspx Hope it helps to much trouble to have some are adding to the table. end of post keywords: Visual Studio .NETSQL Server, uniqueidentifier, clustered, ASP.NET, trigger description: Need advice about membership and sql server Hi All, I need an advise
What is application Control in asp.net? ASP.NET Web server controls are objects on ASP.NET Web pages that run when the page
Can any one explain about What is Http Handler in ASP.NET An ASP.NET HTTP handler is the process (frequently referred to as the "endpoint") that runs in response
i want refer asp.net E book . . which book is better for refer. . pls tell me Hi, Professional ASP.NET 3.5 Book : http: / / weblogs.asp.net / scottgu / archive / 2008 / 05 / 06 / professional-asp-net