smithmrk
asked on
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
For Example the First Name, Last Name, Department, etc.
Thanks,
Mark
ASKER
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
I want to access the ASP Membership Provider through a Windows Application and get the profile information.
Thanks,
Mark
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.
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.
This shows what you need to add to app.config
https://mdrasel.wordpress.com/2011/02/01/asp-net-membership-provider-outside-of-web-application/
http://social.technet.microsoft.com/wiki/contents/articles/3855.how-to-use-a-membership-provider-of-asp-net-in-winform-application.aspx
Complete tutorial
http://www.codeproject.com/Articles/27670/Implementing-Application-Security-with-Client-Appl
https://mdrasel.wordpress.com/2011/02/01/asp-net-membership-provider-outside-of-web-application/
http://social.technet.microsoft.com/wiki/contents/articles/3855.how-to-use-a-membership-provider-of-asp-net-in-winform-application.aspx
Complete tutorial
http://www.codeproject.com/Articles/27670/Implementing-Application-Security-with-Client-Appl
ASKER
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(“testus er”, true);
profile.SetPropertyValue(“ FriendlyNa me”, “testuser”);
profile.SetPropertyValue(“ TagID”, “123321”);
profile.Save();
Thanks,
Mark
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(“testus
profile.SetPropertyValue(“
profile.SetPropertyValue(“
profile.Save();
Thanks,
Mark
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
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
ASKER
OK, so this is what I have:
Try
Dim test As ProfileBase = New ProfileBase
test.Initialize("msmith", True)
MessageBox.Show(test.GetPr opertyValu e("FirstNa me"))
Catch ex As Exception
MessageBox.Show(ex.Message )
End Try
But I'm getting this error message see attached screen shot.
Mark
error.jpg
Try
Dim test As ProfileBase = New ProfileBase
test.Initialize("msmith", True)
MessageBox.Show(test.GetPr
Catch ex As Exception
MessageBox.Show(ex.Message
End Try
But I'm getting this error message see attached screen shot.
Mark
error.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<profile defaultProvider="AspNetSql ProfilePro vider" enabled="true">
<providers>
<clear/>
<add name="AspNetSqlProfileProv ider" type="System.Web.Security. SqlProfile Provider" applicationName="AspNet" connectionStringName="Loca lSqlServer "/>
</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>
<providers>
<clear/>
<add name="AspNetSqlProfileProv
</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>
ASKER
Found my problem!!!
In bold below:
<profile defaultProvider="AspNetSql ProfilePro vider" enabled="true">
<providers>
<clear/>
<add name="AspNetSqlProfileProv ider" type="System.Web.Security.SqlProfileProvider" applicationName="AspNet" connectionStringName="Loca lSqlServer "/>
</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>
In bold below:
<profile defaultProvider="AspNetSql
<providers>
<clear/>
<add name="AspNetSqlProfileProv
</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>
ASKER
Now my problem is this is returning nothing...blank messagebox:
MessageBox.Show(test.GetPr opertyValu e("FirstNa me"))
MessageBox.Show(test.GetPr
However, this means that you are able to grab the profile so its a good start. Try some other properties.
ASKER
Nope, nothing!
They are all coming back blank.
???
Mark
They are all coming back blank.
???
Mark
Is the table populated in DB?
ASKER
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
I keep looking, but so far my connection string, and everything else seems to be working.
Mark
ASKER
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
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
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