.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Programmatically Changing the Profile Provider at Runtime

Posted By:      Posted Date: August 25, 2010    Points: 0   Category :ASP.Net

Dear All

I'm using one application but have multiple providers in my web.config for memberships, roles and profiles to allow my application to be used by different groups of users who need to connect to different databases.

This means I'm having to change the membership, role and profile providers on-the-fly in my code-behind files. So far I've taken care of the membership and roles a bit like this:

Dim RolePV As RoleProvider = Roles.Providers(GetSettingFromFile("Provider"))

However, I'm having trouble finding out how to do the same sort of thing for Profiles. I've looked at ProfileProvider and ProfileManager but I can't work it out how to access my the profile property that I've created in my web.config file called "ScreenSize". Normally you would just write Profile.ScreenSize to read or write to the property.

Please can you help me to understand how I access the profile property called ScreenSize by dynamically setting the profile provider first?

I'd be very grateful for any help or advice.

Many thanks



View Complete Post

More Related Resource Links

Setting Membership/Profile/Role provider's connection string at runtime...?


How can I set the connection string for the built-in membership, profile and role providers at runtime?

Since each site in our multi-site application uses a separate API to retrieve its specific connection string (via key, for security purposes), I cannot set the connection string to my providers in the web.config file. I need to be able to set the connection strings programmatically at runtime, but I cannot find how to implement this.

I thought many people must have run into this problem, but I can't seem to find anything regarding this.Can anyone here help me with this problem?



Profile Provider in Asp.Net MVC

The article Profile Provider in Asp.Net MVC was added by krokonoster on Wednesday, June 02, 2010.

Finding very little information on how to implement Profiles in Asp.Net MVC, I thought I'd share my solution to implement this. For demonstration purposes, let's assume you want to store a user's First and Last Name only. Firstly I created

FBA users (ldap provider) don't have any user profile info when logged in.... what am I doing wrong

Sharepoint 2010, Claims authentication, FBA using ldap membership provider and role provider against Active Directory.  User profiles all imported just fine -- used the LDAP FBA provider hitting Active Directory to do so too.  whenever an FBA user logs in, it doesn't seem like sharepoint is picking up any user attributes.  targeted audiences don't work and MY SETTINGS is blank other than account and name.  If the same user logs in but through Active Directory, everything works just fine... targeted audiences, etc. Am I doing something wrong or can I not use the LDAP provider to authenticate to AD and also use the user profiles from Sharepoint?  GRRRRR.  All this to get around the Windows Authentication popup so I can customize a better looking logon experience.  Help?

Using the SQL Table Profile Provider in ASP.NET 4 Web Applications (C# & VB)

 Just an FYI for those trying to use the SqlTableProfileProvider in a Web application project. Here's my article: Using the SQL Table Profile Provider in ASP.NET 4 Web Applications (C# & VB) http://weblogs.asp.net/kencox/archive/2010/09/05/using-the-sql-table-profile-provider-in-asp-net-4-web-applications-c-amp-vb.aspx The complete projects are here: http://code.msdn.microsoft.com/aspnet4profile   Ken        

Using the SQL Table Profile Provider in ASP.NET 4 Web Applications (C# & VB)

This post and accompanying projects demonstrate how to use Microsoft's SQL Table Profile Provider with an ASP.NET Web application. ASP.NET's built-in Profile provider (SqlProfileProvider) stores Profile data in an oddball, serialized format that's hard to use in queries and may not scale well in large sites. To help developers use a more standard database format, Microsoft posted the source code for a sample provider (SqlTableProfileProvider). It stores each Profile property in a separate database...(read more)

Changing title o sitemapnode at runtime from code behind c#

Hi guys ! I have a site map on my project and I have section which get values from sql database and it changes according to querystring Id value. In my sitemap the title of the page is everytime same. but I want tpo change it at runtime. I am using multiple sitemaps and My sitemap is not the default one. its name is rootSitemap. I tried some code which I got from msdn but it seems doesn't work for me; protected void Page_Load(object sender, EventArgs e) { SiteMap.SiteMapResolve += new SiteMapResolveEventHandler(this.ExpandForumPaths); } private SiteMapNode ExpandForumPaths(Object sender, SiteMapResolveEventArgs e) { // The current node represents a Post page in a bulletin board forum. // Clone the current node and all of its relevant parents. This // returns a site map node that a developer can then // walk, modifying each node.Url property in turn. // Since the cloned nodes are separate from the underlying // site navigation structure, the fixups that are made do not // effect the overall site navigation structure. SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true); SiteMapNode tempNode = currentNode; tempNode.Url = tempNode.Url + "?TransferType=" + Request.QueryString[0].ToString(); tempNode.Title = "My Transfer Desc - " + Request

changing the content of website runtime

say i have a table in my website that contain <tr>  and <td> and "hello good morning" is wriiten over there. how can change the content of my website to "hello good night" on a click of button or using any other way of doing  this like yahoo and other popular website did.

Find SharedService Provider Programmatically

Hello,     When we deploy to testSP I do not know the name of the SSP so this code: FullTextSqlQuery kwQuery = new FullTextSqlQuery(ServerContext.GetContext("My SSP"))) {} no longer works because it is not called "MY SSP".  How can I loop through the Web Applications to find the SSP? Thanks  

Programmatically Uploading User Profile Pictures using Powershell

I've reviewed other solutions for this, but I need clarification on something I'm not getting by reading other posts.  I'm using a powershell script to: 1)  Upload profile pictures on our network into the User Photos picture library in the My Site Host.  This works. 2) Associate a picture to a user profile.  I'm using this command ... $up.get_Item($picturePropertyName).Value = $PortraitUrl ... where $up is the user profile, $picturePropertyName is the property name of the url (PictureUrl), and $PortraitUrl is the full path to the picture uploaded in point 1 above.  This isn't working. 3) Eventually I will be executing the Update-SPProfileStore command to automatically resize the images once they've been added. Clarification required ... when I associate a picture to the user profile in step 2 above, is this what will automatically generate the 3 thumbnails for me (in the Profile Picture folder)?  Or ... do I have to manually create the 3 images?  Or ... will it associate the image I've provided and then the Update-SPProfileStore command will create the 3 resized images for me? I notice that when I associate a picture to a profile using the 'Edit my Profile' UI, it automatically creates the thumbnails for me.  I'm just not understanding how these pieces fit together.  I see some code snippets out there for r

Profile Provider


Hi All,

I'm trying to implement on a MVC2 web application tha authentication. I successfully use standard Roles and Login through default Membership Provider, I can store usernames, passwords ,roles, assign roles to users etc. I'm not able to expand the user data. I need to save personal information such as address, phone numbers etc.

I try to implement a custom ProfileProvider following some tutorial online:

	public class UserProfile : ProfileBase
		#region Properties

		public string FirstName
			get { return base["FirstName"] as string; }
			set { base["FirstName"] = value; }

		public string SecondName
			get { return base["SecondName"] as string; }
			set { base["SecondName"] = value; }

		public string LastName
			get { return base["LastName"] as string; }
			set { base["LastName"] = value; }


		public static UserProfile GetUserProfile(string username)
			return Create(username) as UserProfile;

but I can't find a method to show the whole list of user. I saw that the ProfileProv

Programmatically changing the 'Activities I am following' under Newsfeed Settings

Hi, is it possible to programatically select/deselect activities I am following on the news feed preferences page under MySites? I want to be able switch on/off notifications for both custom events and those provided by Sharepoint 2010 out-of-the-box.

Changing the address in app.config at runtime ..AN ISSUE..HELP neede..

hi wcf champs.,

hmm...I have a problem..and seriously need a solution to get things done well..!!

Have developed a wcf Upload application,the wcf service is hosted on IIS..now,the endpoint address at the server is exposed at client(in app.config).If further the server ip changes to some other..then the address at the client must be changed..!right..ya I did something to handle this but ,its another problem..!!.

Let me say what i have done and why does that give a problem..


*.*.The server ip is stored in a xml file.When the application runs,it picks up the server ip and changes it in Client.exe.config...

*.And if there is EndpointotFound exception at the client,it asks the admin to check the ip of the server.

*.The admin checks it and if the server ip is changed,the admin changes the ip in the xml file (where server ip is stored).

now let me know.."IS THIS A RIGHT APPROACH TO SOLVE MY PROBLEM" ..But then there is a problem!!let me share that with u..


*.The ip that is picked from  xml and placed in Client.exe.config.

Programmatically Upload Pictures to SharePoint Profile Picture Store using Powershell


I'm trying to create a powershell script that will bulk upload pictures to the SharePoint Profile Picture Store located in a "http://sp2010/my/User Photos/Profile Pictures".  I found Chris Johnson's blog post ( http://blogs.msdn.com/b/cjohnson/archive/2010/05/08/sharepoint-2010-office-2010-and-profile-pictures.aspx )  extremely useful.  However, the SPUtils.ps1 that is referenced on his site doesn't seem to support uploading to the "Profile Pictures" folder within the "User Photos" picture library at "http://sp2010/my/User Photos".  My account has full control of the "User Photos" picture library and the "Profile Pictures" folder, and I can upload to the "User Photos", root directory with no problems.  The file fails to upload to the "Profile Pictures" folder.

Currently my Powershell script processes a folder of pictures.  First, it pulls the file name and does some manipulations to retrieve the employee number of the employee.  Second, it performs an active directory search to get the employee's user name.  Third, it resizes the photo to match the small, medium, and large thumbnails generated by a traditional manual upload of a photo from the user's edit profile page.  After each creation of the resized picture it uploads the picture t

Changing crid cell content at runtime


In a cell in a grid, I have a TreeView. When the parsing of the data behind the treeview yields an error, I would like to replace the treeview with a textblock with information on the error details.

I'm thinking about using a datatemplateselector, but I can't figure out how, or if this is the best approach. Any suggestions?

Alternatively I will place a ContentControl in the grid cell and populate it with the correct content from the code behind file, I just think there could be a more elegant solution in pure XAML.

User profile sync failing after changing username when another administrator got married recently.

I changed the username in Active Directory for the administrator who set up most of our Sharepoint 2010 server and now neither she nor I (as domain admin) can manage library settings, services on farm, or a number of other places where apparently sharepoint relies on user profile sync to succeed to grant privileges.  Checking back in the logfiles, it would appear that sharepoint profile sync hasn't been working since the last cumulative update but no one noticed (I don't adminster the server) until the sharepoint admin user person got married and their username (and display name) changed.  Since then, many links are broken in both central admin and all other sites.  The error is always the following (the date/time changes obviously):  "


User cannot be found.


Troubleshoot issues with Microsoft SharePoint Foundation.

Correlation ID: a13766dc-6604-46ef-9abc-e5daade

Changing fonts at runtime


Is it possible to change a font at runtime? I am using reporting service to generate letters. Some letters use a different font (can based on a field value), but I don;t really want to use a separate report for each one.

Custom Profile Provider and Role - Mysql


May I ask if how can I create a custom mysql profile provider with the following properties?

                <add name="ProjectID" type="Int" defaultValue="0"/>
                <add name="TeamID" type="Int" defaultValue="0"/>
                <add name="EmployeeID" type="String" serializeAs="String"/>
                <add name="LastName" type="String" serializeAs="String"/>
                <add name="FirstName" type="String" serializeAs="String"/>
                <add name="MiddleName" type="String" serializeAs="String"/>
                <add name="NickName" type="String" serializeAs="String"/>

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend