简体   繁体   English

从C#本地服务获取已安装的IIS Web应用程序的路径

[英]Get path to installed IIS web application from a C# local service

I have two projects developed with C#, .NET in VS 2010: One is an ASP.NET web application and the second one is a C# Windows service that runs as a local system. 我有两个使用VS 2010中的C#、. NET开发的项目:一个是ASP.NET Web应用程序,第二个是作为本地系统运行的C#Windows服务。 The web application is installed and run on the same physical machine via IIS. 该Web应用程序通过IIS安装并在同一台物理计算机上运行。

My question is, how to get the path to my web application installation folder on this machine from the service? 我的问题是,如何从服务获取到此计算机上Web应用程序安装文件夹的路径?

I assume your are using IIS 7.5 and you know web application name. 我假设您使用的是IIS 7.5,并且您知道Web应用程序的名称。 If so you can use ServerManager from Microsoft.Web.Administration assembly to get the physical path. 如果是这样,则可以使用Microsoft.Web.Administration程序集中的ServerManager来获取物理路径。

Here is link on how to user the class ServerManager How to get site's physical path on disk? 这是有关如何使用类ServerManager的链接如何获取磁盘上站点的物理路径?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM