Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8148713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:41:59+00:00 2026-06-06T14:41:59+00:00

I have a Web Role that is using the ASP.NET SQL Membership provider. Currently

  • 0

I have a Web Role that is using the ASP.NET SQL Membership provider. Currently the configuration is in the Web.Config file. I would like to configure the connection string as a Web Role setting instead of having it in the Web.Config. The main reason that I wan this is so that I can set up configurations on the azure project to publish to different hosted services (dev, qa, etc.) Right now, I have to manually edit the web.config each time I want to publish to a different service.

I have a couple ideas on how I might be able to accomplish this.

  1. Write a custom membership provider that wraps the SQL provider and provides custom configuration to it.
  2. Put something in the Web Role OnStart method to change the connection string in the Web.config file.

Has anyone done something like this before, or have recommendations on which option might be best, or have another idea on how to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:42:00+00:00Added an answer on June 6, 2026 at 2:42 pm

    The Windows Azure SDK allows you to have multiple service configurations per environment. But web.config modifications are a bit harder. In your case I would suggest you write some code (or a startup task) that reads the connection string from the service configuration and writes it to the web.config.

    Andy’s blog post ‘Programmatically modify web.config on WebRole Startup‘ explains exactly how you can do this:

    public override bool OnStart()
    {
        using (var server = new ServerManager())
        {
            // get the site's web configuration
            var siteNameFromServiceModel = "Web"; // TODO: update this site name for your site. 
            var siteName =
                string.Format("{0}_{1}", RoleEnvironment.CurrentRoleInstance.Id, siteNameFromServiceModel);
            var siteConfig = server.Sites[siteName].GetWebConfiguration();
    
            // get the appSettings section
            var appSettings = siteConfig.GetSection("appSettings").GetCollection();
    
            AddElement(appSettings, "deploymentId", RoleEnvironment.DeploymentId);
            AddElement(appSettings, "internalEndpointPort", RoleEnvironment.CurrentRoleInstance.InstanceEndpoints
                .First(t=>t.Key=="InternalEndpoint1").Value
                .IPEndpoint.Port.ToString());
    
            server.CommitChanges();
        }
        return base.OnStart();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Azure web role that contains a web site using ASP.NET
We have an ASP.NET MVC3 based Web role running on the Azure cloud, using
I have an asp.net web app that uses forms-based authentication, a SqlMembershipProvider (using an
I'm developing ASP.NET 4.0 Website using SQL server 2008 with Membership Framework. It runs
I have a few users setup in the web.config of an asp.net site to
I have an ASP.Net application that is using Windows Authentication and I have specified
I'm using ASP.NET Sitemaps with a custom Role Provider to generate a site Menu
I'm building a web app using EF Code First and ASP.NET MVC. I have
I'm working on a web application that uses the ASP.NET 2.0 Membership and Roles
We have a Web Role that we are hosting in Windows Azure that uses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.