How to get the IIS virtual dir & web application's physical paths with C# code?

后端 未结 3 1829
你的背包
你的背包 2020-12-06 03:41

I am writing a web application deployment verification tool and I need to check the physical folder structures of Web Applicatons and Virtual Folders.

How can this

3条回答
  •  我在风中等你
    2020-12-06 04:39

    Take a look at the HttpRequest object. You can get the current URL using HttpContext.Current.Request.Url.

    If you wanted to check that a virtual IIS folder existed you could try performing a Server.MapPath call to the relative URL you expect to exist (again you'll find this in the HttpContext object) and if the mapping is not successful you could then assume that a specific subfolder as specified by your relative path does not exist.

提交回复
热议问题