开发者

Is there a universal MapPath function for both client-side and server-side apps?

开发者 https://www.devze.com 2023-02-23 15:54 出处:网络
What is the universal MapPath equivalent to the below? Universal, meaning, that I could use it in both client-side and server-side .NET apps, not just in server-side apps.

What is the universal MapPath equivalent to the below? Universal, meaning, that I could use it in both client-side and server-side .NET apps, not just in server-side apps.

System.Web.Hosting.HostingEnvironment.MapPath(virtualPath)

The reason I'm asking is I want to reuse the same piece of code in MVC.NET server-side apps, but as well in .NET standalone apps running on the clien开发者_Python百科t machine. Therefore I want to have a universal function to map my virtual paths to within my App's root folder.


There is no universal method for that, because there is no exact equivalent of the web root in a desktop application.

You could roll your own method that does different things depending on whether a web context exists or not, but then you would have to reference the System.Web dll in all your desktop applications also, which would certainly contradict any gain you are trying to make by reusing some of your code.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号