Solved

Programatically edit Web.config

Posted on 2014-03-19
8
49 Views
Last Modified: 2016-05-19
In my app we allow users to create different instances, each instance has to have access to the profile system.

How do I go about adding  sections (into the profile section) programmatically when a new instance is created.

Andy
0
Comment
Question by:Andy Green
[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
  • 2
8 Comments
 
LVL 21

Expert Comment

by:Dale Burrell
ID: 39939207
What do you mean by an instance? I assume you can't use the regular profile management classes.

Keep in mind that if you edit web.config on the fly the app restarts which can be annoying to users. Its not the ideal place to store information which the user can change.
0
 
LVL 3

Author Comment

by:Andy Green
ID: 39939221
I mean they can set up an instance to run in a particular location, In each location the users will have their own profiles.

this is my current profile section, I want to copy a group with a new id.

        <!--When a new site group is added, create a new SiteGroupPreferences_n where n is the Sitegroup_ID from the database-->
        <group name="SiteGroupPreferences_1">
          <add name="Location_ID" type="System.int32" />
          <add name="Location" type="System.string" />
          <add name="Status" type="System.string" />
          <add name="TimeOffset" type="System.int32" />
          <add name="Session" type="System.string" />
          <add name="Activity" type="System.int32" />
        </group>
        <group name="SiteGroupPreferences_2">
          <add name="Location_ID" type="System.int32" />
          <add name="Location" type="System.string" />
          <add name="Status" type="System.string" />
          <add name="TimeOffset" type="System.int32" />
          <add name="Session" type="System.string" />
          <add name="Activity" type="System.int32" />
        </group>

Open in new window

0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 39983677
Is that custom profile or built-in ASP.NET profiles section? I don't recall built-in Profiles having grouping. And as mentioned above, modifying web.config on the fly isn't a good idea. See if you can use database for this custom profiles.
Though here's an example modifying contents of web.config
0
 
LVL 3

Author Comment

by:Andy Green
ID: 39985193
Thanks I will take a look. This is the standard out of the box ASP.Net profiles API. Don't really want to write a new one if we can help it.

Andy
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

717 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