why use @Url.Content

前端 未结 1 399
情话喂你
情话喂你 2020-12-09 09:22

Can someone please explain why I should use (or should I?):



        
相关标签:
1条回答
  • 2020-12-09 09:50

    The fragment @Url.Content("/Scripts/SomeScript.js") does absolutely nothing, and is equivalent to just /Scripts/SomeScript.js.

    However, for paths starting with "~", it will translate the url to the correct, application relative url, e.g., @Url.Content("~/Scripts/SomeScript.js") could translate to /MyVirtualDirectory/Scripts/SomeScript.js, if you deployed your web application to a virtual directory MyVirtualDirectory below the root folder of the web site.

    0 讨论(0)
提交回复
热议问题