Solved

Programatically edit Web.config

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LINQ - C# to VB convertion 12 46
Problem with Filesystemobject or .NET version 3 34
Error on Add method 1 38
Entity Framework 7 31
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

910 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

18 Experts available now in Live!

Get 1:1 Help Now