?
Solved

Custom MembershpUser

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

765 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