Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing an asp.net application using webservice. But as of now my webservice is in test domain.so the link is say link1. So I'm using the link to create instance of webservice.
link1.service serv=new link1.service;

But I've to upload the service to a different domain latter.So I've to change the link say link2.

But I don't want to write code in this way.I want to set a variable or something globally for my asp app and use the variable all over the app.In this way,if I change the variable (or the storage) name with the new link,then I don't have to change code all the pages.

I hope I can make you understand.So please tell me a way to do this.Can I set this in web.config?If yes,then how?
Posted
Comments
souvikcode 12-Jan-15 4:06am    
When adding the webreference if I change the default name,then I can use the name as service name.Now My question is,is this way applicable for webservice is in local machine and in server?

1 solution

I believe you are only changing the URL. In that case, when we add a service or web reference, there is an entry made in app.config or web.config file which points to service URL. You can simply change that. An example app.config file the a web reference will have an entry like this:

XML
<applicationSettings>
        <ConsoleApplication1.Properties.Settings>
            <setting name="[SettingNameHere]" serializeAs="String">
                <value>[ASMX URL here]</value>
            </setting>
        </ConsoleApplication1.Properties.Settings>
    </applicationSettings>
 
Share this answer
 
Comments
souvikcode 12-Jan-15 4:39am    
Yes,when I add a webservice then setting is created automatically in web.config.
add key="kitesRef.KitesService" ..value="" ...=""
but if i change
add key="kitesRef2.KitesService" ...=""
code is using the old kitesref not kitesref2. so renew name is not affecting code.

I think if I change the value url with same name,then I can access the new url by the old name,isn't it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900