473,473 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Obtain server path in web services

Hi,

I have a WCF service deployed in IIS. How could I get the physical server
path that the service resides, inside the service code?

--

Thanks.

Daniel
Aug 10 '07 #1
6 17893
On Aug 10, 4:42 am, Daniel <daniel.s...@newsgroup.nospamwrote:
Hi,

I have a WCF service deployed in IIS. How could I get the physical server
path that the service resides, inside the service code?

--

Thanks.

Daniel
I get access to the physical path in my global.asax.cs file in the
Application_Start event using ...

Context.Request.PhysicalApplicationPath

If inside a method, I think you can use...

HttpContext.Current.Request.PhysicalApplicationPat h

Ron

Aug 10 '07 #2
Thanks Ron. I think I have tried this approach, but it seems that
HttpContext.Current is null at my site. I guess this is for ASP.NET web
services only.

Daniel
"ro*************@yahoo.com" wrote:
On Aug 10, 4:42 am, Daniel <daniel.s...@newsgroup.nospamwrote:
Hi,

I have a WCF service deployed in IIS. How could I get the physical server
path that the service resides, inside the service code?

--

Thanks.

Daniel

I get access to the physical path in my global.asax.cs file in the
Application_Start event using ...

Context.Request.PhysicalApplicationPath

If inside a method, I think you can use...

HttpContext.Current.Request.PhysicalApplicationPat h

Ron

Aug 13 '07 #3
Hi Daniel,

Regarding on the question you mentioned, I think the problem here is that
WCF service is unlike ASP.NET web application or webservice which is not
quite coupled with ASP.NET runtime engine and pipeline. That's why we can
not quite use the ASP.NET specific approaches to get the path or virtual
path.

Currently, I've tried the .NET AppDomain based approach to get the running
WCF AppDomain's base directory, and it seems can point to the hosted
application directory's physical root directory path. here is a test code
snippet demonstrate this:

================
public class Service : IService
{
public string SayHello(string name)
{

return "Hello " + name + "\r\n" +
AppDomain.CurrentDomain.BaseDirectory;
}

................
======================

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 13 '07 #4
On Aug 12, 8:14 pm, Daniel <daniel.s...@newsgroup.nospamwrote:
Thanks Ron. I think I have tried this approach, but it seems that
HttpContext.Current is null at my site. I guess this is for ASP.NET web
services only.

Daniel

"ronscottlang...@yahoo.com" wrote:
On Aug 10, 4:42 am, Daniel <daniel.s...@newsgroup.nospamwrote:
Hi,
I have a WCF service deployed in IIS. How could I get the physical server
path that the service resides, inside the service code?
--
Thanks.
Daniel
I get access to the physical path in my global.asax.cs file in the
Application_Start event using ...
Context.Request.PhysicalApplicationPath
If inside a method, I think you can use...
HttpContext.Current.Request.PhysicalApplicationPat h
Ron
Yep, correct. Fyi, it is possible to use the ASP.NET values in WCF
services if you are running in ASP.NET Compatibility mode.

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

Because of some limitations with WCF Sessions, I am running in this
mode and have access to the HttpContext values, as well as the Session
and Application variables.

Ron

Aug 13 '07 #5
Thanks for Ron's informative input,

Hi Daniel,

I agree that the "enable aspNetCompatibility" for the WCF host should be a
good solution here.

Also, you can read some additional comments about this setting to see
whether it does fully meet your requirement:

#<serviceHostingEnvironment>
http://msdn2.microsoft.com/en-us/library/ms731336.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Aug 14 '07 #6
Hi Daniel,

Have you got progress on this or does our suggestion help you on this
issue? If there is anything else we can help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Aug 16 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information...
1
by: Michiel | last post by:
Which MSDN CD's exactly must I install to obtain a web services development environment (e.g. with C#) on my Win2k laptop. Presumably Visual Studio .NET, but what version exactly? And what else? We...
7
by: Sam | last post by:
Hi, I can use System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() to obtain the path for ILASM.exe, but how can I obtain the path to ILDASM.exe? Examples of the path I'm...
0
by: Henrique Berenguel | last post by:
Hello folks. How do I solve the problem below? when my program executes the line below : Package.WriteXml(Server.MapPath(strID + ".XML")); Ireceive the following error message: ...
8
by: Woody Splawn | last post by:
I am asking this question here because I asked this question in the Reporting Services Newsgroup and did not get an answer. Does anyone know if Reporting Services is intended to work in a...
8
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really...
0
by: Daniel | last post by:
I wrote a pretty neat website today that can utilize no postback AJAXIAN type features. Basically to populate a drop down with a web service call that hits a SQL server, based off the change of...
0
by: Orbit | last post by:
Hi, I hope someone could help me. I have a simple web service that I developed on my laptop that resides within a large web application. It queries Northwind & presents the data in a grid in the...
0
by: BobLewiston | last post by:
I did a full installation of SQL Server 2008 Express. Looking at Add / Remove Programs, I see the following pertinent programs installed: SQL Server 2008 SQL Server 2008 Browser SQL Server 2008...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.