为什么<link using =“”<%=“rootDir%”/>而不是根文件夹?

时间:2014-05-14 00:30:55

标签: asp.net

给出一棵树 -

C:\mydirINET\\Central35webapp
    example_A.aspx
    example_B.aspx
---->\App_Themes
-------->\Styles
------------SABT_template.css

There is code in Page_Load that resolves--

// get the root directory
string rootDir = page.ResolveUrl("~");

Here are two html fragments.
Are these two examples equivalent?
Why would one be used rather than another?
Are either of these customary in a particular ASP.NET version?

example_A
<link href="<%=rootDir%>/Styles/SABT_template.css" rel="stylesheet" type="text/css">

example_B
<link href="/App_Themes/Styles/SABT_template.css" rel="stylesheet" type="text/css" />

tkx,donPablo

1 个答案:

答案 0 :(得分:0)

page.ResolveUrl说明可能未在主机上生根的IIS应用程序。

如果您的应用程序位于app目录中,则/app_themes...将不正确。