Abirami Rajendran
asked on
Web Service Application Path
How can we get the application path for a webservice?
In ASP.NET we can use HttpContext.Current.Server .MapPath(H ttpContext .Current.R equest.App licationPa th)
But 'HttpContext' doesnt work inside a web service.
Can some body help? Thanks
In ASP.NET we can use HttpContext.Current.Server
But 'HttpContext' doesnt work inside a web service.
Can some body help? Thanks
u should use Server.MapPath
see this:
http://msdn2.microsoft.com/en-us/library/system.web.httpserverutility.mappath(vs.71).aspx
ASKER
Thanks for the reply
I cant use the SERVER_NAME and URL as i dont want to hard-code the name & httpcontest doesnt worh inside a web service. So i cant use server.mappath.
I cant use the SERVER_NAME and URL as i dont want to hard-code the name & httpcontest doesnt worh inside a web service. So i cant use server.mappath.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again. System.Web.Current.HttpCon tect.Reque st.ServerV ariables(" SERVER_NAM E") doesnt seems to be working in the class that i have in my webservice. It gives error.
AppDomain.CurrentDomain.Ba seDirector y seems to give the path but "\bin\Debug"
AppDomain.CurrentDomain.Ba
If you give the error, I might be able to help debug it. I did just notice I had some namespaces reversed though. You need to do:
System.Web.HttpContext.Cur rent.Respo nse.Server Variables
instead of
System.Web.Current.HttpCon tect.Reque st.ServerV ariables
I have a .Net 2.0 and .Net 1.1 webservice that use this same code for error handling.
System.Web.HttpContext.Cur
instead of
System.Web.Current.HttpCon
I have a .Net 2.0 and .Net 1.1 webservice that use this same code for error handling.
ASKER
Thanks. When I try to use System.Web.HttpContext.Cur rent.Respo nse.Server Variables i get the error
'ServerVariables' is not a member of 'System.Web.HttpResponse'
'ServerVariables' is not a member of 'System.Web.HttpResponse'
Change "Response" to "Request" and you should be set.
ASKER
Thanks. I did but this i what i get as error Referenced object has a value of 'Nothing'.
ASKER
Okay. I figured the problem. In development env. I have a vb form that calls the web service. So when the vb form calls the web servce, there is no HttpContext. so I get the error, When the service is hosted and i try to call from the VB app it works. Thanks !!
HttpContext.Current.Reques