VB.net 2013 - Windows Forms ASP Membership Provider - Profiles?

I'm using the ASP.net Membership Provider in my Windows Application, but I can't seem to figure out how to access the Profile Information?

For Example the First Name, Last Name, Department, etc.

Thanks,
Mark
smithmrkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Did you define the profile properties in the web.config?

<profile>
	<properties>
		<add name="Name" allowAnonymous="true"/>		
		<add name="VisitedOn" type="System.DateTime" allowAnonymous="true"/>			
	</properties>
</profile>

Open in new window


Implementing User Profiles in ASP.NET - A Beginner's Guide
http://www.codeproject.com/Articles/420052/Implementing-User-Profiles-in-ASP-NET-A-Beginners#33
0
smithmrkAuthor Commented:
Windows Application...so there is no web.config, only the app.config.
I want to access the ASP Membership Provider through a Windows Application and get the profile information.

Thanks,
Mark
0
Bob LearnedCommented:
Mark,

That is outside of what I have ever worked with.  I would think that if you put the configuration in the app.config file, that it might work.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

smithmrkAuthor Commented:
Sorry it has taken me so long to get back to you...

This one here is my best lead:
https://mdrasel.wordpress.com/2011/02/01/asp-net-membership-provider-outside-of-web-application/

However, it only shows me how to create a profile...I already have the profiles created I just need to get the information from the profile.  How can I do that?

ProfileBase profile = ProfileBase.Create(“testuser”, true);
profile.SetPropertyValue(“FriendlyName”, “testuser”);
profile.SetPropertyValue(“TagID”, “123321”);
profile.Save();

Thanks,
Mark
0
CodeCruiserCommented:
Use the Initialize method to get the profile

https://msdn.microsoft.com/en-us/library/ms151831(v=vs.110).aspx

and then use GetPropertyValue to get values of profile properties

https://msdn.microsoft.com/en-us/library/system.web.profile.profilebase.getpropertyvalue(v=vs.110).aspx
0
smithmrkAuthor Commented:
OK, so this is what I have:

Try
            Dim test As ProfileBase = New ProfileBase
            test.Initialize("msmith", True)

            MessageBox.Show(test.GetPropertyValue("FirstName"))
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

But I'm getting this error message see attached screen shot.

Mark
error.jpg
0
CodeCruiserCommented:
What is Type set to in your app.config for profile provider? It should be type=”System.Web.Profile.SqlProfileProvider”
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
smithmrkAuthor Commented:
<profile defaultProvider="AspNetSqlProfileProvider" enabled="true">
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Security.SqlProfileProvider" applicationName="AspNet" connectionStringName="LocalSqlServer"/>
      </providers>
      <properties>
        <add name="FirstName" type="string"/>
        <add name="LastName" type="string"/>
        <add name="JobTitle" type="string"/>
        <add name="Gender" type="string"/>
        <add name="ProfileImageID" type="string"/>
        <add name="Department" type="string"/>
        <add name="PhoneNumber" type="string"/>
        <add name="MobilePhone" type="string"/>
      </properties>
    </profile>
0
smithmrkAuthor Commented:
Found my problem!!!
In bold below:

<profile defaultProvider="AspNetSqlProfileProvider" enabled="true">
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Security.SqlProfileProvider" applicationName="AspNet" connectionStringName="LocalSqlServer"/>
      </providers>
      <properties>
        <add name="FirstName" type="string"/>
        <add name="LastName" type="string"/>
        <add name="JobTitle" type="string"/>
        <add name="Gender" type="string"/>
        <add name="ProfileImageID" type="string"/>
        <add name="Department" type="string"/>
        <add name="PhoneNumber" type="string"/>
        <add name="MobilePhone" type="string"/>
      </properties>
    </profile>
0
smithmrkAuthor Commented:
Now my problem is this is returning nothing...blank messagebox:

MessageBox.Show(test.GetPropertyValue("FirstName"))
0
CodeCruiserCommented:
However, this means that you are able to grab the profile so its a good start. Try some other properties.
0
smithmrkAuthor Commented:
Nope, nothing!
They are all coming back blank.

???

Mark
0
CodeCruiserCommented:
Is the table populated in DB?
0
smithmrkAuthor Commented:
Yes, because it works fine when I log into my Web Page side of the house...but doesn't seem to pull the values in the Windows Application.

I keep looking, but so far my connection string, and everything else seems to be working.

Mark
0
smithmrkAuthor Commented:
OK, I finally figured this out!
It did have to do with my app.config file.

This is what I have now and works:

    <profile enabled="true">
      <properties>
        <add name="FirstName" type="string"/>
        <add name="LastName" type="string"/>
        <add name="JobTitle" type="string"/>
        <add name="Gender" type="string"/>
        <add name="ProfileImageID" type="string"/>
        <add name="Department" type="string"/>
        <add name="PhoneNumber" type="string"/>
        <add name="MobilePhone" type="string"/>
      </properties>
    </profile>

Thanks,
Mark
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.