asp.net怎么获取相对目录呢?
比如我在根目录要链接到test/a.htm
我在Default.aspx写
<a href="~/test/a.htm">hello</a>
运行后链接却指向了
http://localhost:3352/WebSite2/~/test/a.htm
链接错了
[解决办法]
<a href="<%=Page.ResolveUrl("~")%>test/a.htm">hello</a>
[解决办法]
~/只能使用在服务器控件和服务器端。你不能使用在html中的
参见
http://dotnet.aspx.cc/file/Getting-Website-absolute-path-in-asp.net.aspx
[解决办法]
<a href="~/test/a.htm" runat="server" >hello</a>