converting virtual path to actual web path in ASP.NET

后端 未结 3 1646
太阳男子
太阳男子 2021-01-30 21:32

I have a virtual path (example: \"~/Images/Banner.jpg\") and I want to make that an absolute web path (example: \"/ApplicationRoot/Images/Banner.jpg\"). There is a method tha

3条回答
  •  没有蜡笔的小新
    2021-01-30 22:09

    There are various ways that are available in ASP.NET that we can use to resolve relative paths to absolute Urls -

    1) Request.ApplicationPath
    2) System.Web.VirtualPathUtility
    3) Page.ResolveUrl
    4) Page.ResolveClientUrl

    Here's a article that explains the difference between the various ways to resolving paths in ASP.NET -

    Different approaches for resolving URLs in ASP.NET

提交回复
热议问题