I have written feature which updates web.config in inetpub folder under default port 80. It updates web.config with service model. This is not complete code but some code in featureeventreceiver

string endpointbindings = @"<system.serviceModel>
                            <binding name=""CustomBinding_ICalcService"">
                                <security mode=""None"" />
                            <endpoint address=""http://myservice/CalcService.svc""
                                binding=""wsHttpBinding"" bindingConfiguration=""CustomBinding_ICalcService""
                                contract=""CalcService.ICalcService"" name=""CustomBinding_ICalcService"" />

        webApplication = properties.Feature.Parent as SPWebApplication;

        webApplication .Update();


Now i want to depoy this package in different environments like Test env, Integration env and Production env. I want to change service model with different endpoint address as per environment where solution will be deployed. How i identify if its production env or test env or integration env.

1 Answer 1


There are many ways to automate this

  1. Identify current URL and put if..else condition to load appropriate endpoint address

  2. Store endpointbindings xml in a list (hidden from end user) or read it from Web Property Bag(User SharePoint Designer or PowerShell for setting the value). On feature activation read it from that list/property bag and make the update in web config file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.