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
Solved

Programatically edit Web.config

Posted on 2014-03-19
8
36 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Open a link in vb.net 2 16
ASP.NET Content Page 3 28
SSIS Start 2 20
Visual Studio npm 1 12
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

860 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