Solved

Programatically edit Web.config

Posted on 2014-03-19
8
27 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
  • 2
8 Comments
 
LVL 21

Expert Comment

by:Dale Burrell
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to count occurrences of each item in an array.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now