Solved

Custom MembershpUser

Posted on 2007-11-13
5
380 Views
Last Modified: 2008-02-01
I have created a custom MembershipUser class..

Public Class CustomMembershipUser
    Inherits MembershipUser

How do I define this in my web.config file?

thanks!
0
Comment
Question by:Starr Duskk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 16

Accepted Solution

by:
anoyes earned 500 total points
ID: 20276709
You don't have to do anything to web.config to get your custom MembershipUser class to work.  You do, however, have to modify the MembershipProvider.  If you don't already have a custom MembershipProvider, you have to start there.  If you do, take a look at this article from MS regarding implementing custom MembershipUsers: http://msdn2.microsoft.com/en-us/library/ms366730.aspx

If you need to do a custom MembershipProvider, there are a ton of tutorials out there, but here's one that I used when I started implementing my custom MP: http://www.devx.com/asp/Article/29256/0/page/
0
 
LVL 27

Expert Comment

by:Sammy
ID: 20277715
actually you have to set your Custom provider as the default provider for the application
   
<membership defaultProvider="CustomMembershipUser" >
      <providers>
     <clear />
        <add name="CustomMembershipUser"
          type="CustomMembershipUser" />
      </providers>
    </membership>
0
 
LVL 16

Expert Comment

by:anoyes
ID: 20277761
Right, but he hasn't created a membership provider, he's only created a membership user.  I probably should have been more specific - you don't have to do anything to web.config assuming you've already got your provider configured properly.  I don't believe you can set a MembershipUser class as a membership provider...
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20280931
Yes, I have the custom provider in the web.config, I just want to clarify some things after looking at that example.

In the link you gave me, the GetUser references the MembershipUser...

Public Overrides Function GetUser(ByVal username As String, _
                                  ByVal userIsOnline As Boolean) As MembershipUser

Then it knows my custom user exists, because I name it here, but I don't inherit, import or implement it in anyway?

Dim u As OdbcMembershipUser = Nothing

which I'm assuming that means it now says, there is my class, set this "u" as my custom class.

Then in the example, the GetUser method it calls:

u = GetUserFromReader(reader)

And in the GetUserFromReader it does this....

            Dim u As MembershipUser = New MembershipUser(Me.Name, _
                                                  username, _
                                                  providerUserKey, _
                                                  email, _
                                                  passwordQuestion, _
                                                  comment, _
                                                  isApproved, _
                                                  isLockedOut, _
                                                  creationDate, _
                                                  lastLoginDate, _
                                                  lastActivityDate, _
                                                  lastPasswordChangedDate, _
                                                  lastLockedOutDate)


If I refer back to the custom user code... there is a:

Public Sub New(ByVal providername As String,

but I have also seen it written in other examples as....

Public Sub New(ByVal membershipProvider As MembershipProvider,...

which should it be... String or MembershipProvider?

Okay, those things should probably clarify it for me.

thanks!



0
 
LVL 16

Expert Comment

by:anoyes
ID: 20282827
I'm not sure I entirely understand your questions, but...The only place you have to do inheriting is in the actual class for the custom user, like you showed in your initial post.  Get user, when it returns u, is just returning your custom user as an object.  ProviderName as String should be fine.  If I haven't answered your questions could you please clarify?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question