Programmatically change WCF Services EndPoint Address in ASP.Net

pdepirro
 
on Apr 21, 2017 01:55 AM
5322 Views

I currently have a wcf web service that is referenced by my hosted application and have configured the web.config file with the end-point. I need to be able to dynamically chand the eddredd for the endpoint upon login. Can someone help me with this?

Download FREE API for Word, Excel and PDF in ASP.Net: Download
kalpesh
 
on Apr 21, 2017 02:08 AM

Refer the below link for your reference how to modify webconfig dynamically.

Change (Modify) connection string in Web.Config at Runtime in ASP.Net using C# and VB.Net

pdepirro
 
on Apr 21, 2017 08:40 AM

Hey Kalpesh. Thanks for the response but this klink is for a dynamic connection string. I am looking for help on Dynamic End Points for my Web Services. Basically, I want to change the URI Address of the Web Services when the user logs in. When the user logs in, I will check to see the company they are associated with, get the web service address and use the dynamically created endpoint to call the web service. My web.config is below but this is hard coded in web.config.

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="AccountXML" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://hpsm-dev.azurewebsites.net/Services/OAuthService.svc"
        binding="basicHttpBinding" bindingConfiguration="AccountXML"
        contract="OAuthService.IOAuthService" name="AccountXML" />
    </client>   
  </system.serviceModel>    

 

pdepirro
 
on Apr 24, 2017 10:14 AM

Hey Mumbai, I believe the 1st article really doid the job!! Thanks. I just want to leave this open for another day while I test and verify the working model and then I will mark as the answer. Thanks again!!