views:

64

answers:

3

I have a ASP.NET application. Inside the asp.net application I have a folder called WebServices where I keep all the .asmx files.

I am referring these asmx files inside asp.net .cs files. Instead of giving the full url to the webservice.url property how can i set the path like this.

 ds.Url = this.ResolveUrl("~/WebServices/xxx.asmx"); 
A: 

Is HttpServerUtility.MapPath what you're looking for?

ds.Url = Server.MapPath("~/WebServices/xxx.asmx");

You can get hold of it either via Server property in Page class, or via HttpContext.Current.Server chain.

Even better, I'd store this URL in an application configuration file.

Anton Gogolev
Server.MapPath refers to the physical path. so it's throws an exception. is there any other way?
kakopappa
A: 

why don't you store webservice url in web.config file

saurabh
A: 

Your questions suggests that you have your webservices in the same project as the consuming apllication. This will not work. Move all your webservices into a seperate project.

citronas