Вопрос

Hi I am programming in C# and building a website. I am trying to use AppSettings in the web config to set paths to image folders so that I can use those AppSettings anywhere in the site to sort of use as a shortcut to the image folders. I can not figure out how to get the main root of the website so that I can just call this from any folder and get the right path.

Это было полезно?

Решение

This also returns the root:

<img src="~/apps/thisapp/images/logo.gif" alt="" runat="server" />

Or

Server.MapPath("~")

Другие советы

you can get by HostingEnvironment.ApplicationPhysicalPath

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top