Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Custom MembershpUser

Posted on 2007-11-13
5
Medium Priority
?
382 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 2000 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 Ageil
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

610 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