ASP.NET root path

2019-08-02 20:38发布

I have my app written with all the links relative to the root path. Now, when I upload it to the server, the server has two additional levels like /apps/thisapp/ so all my links(those not run on server) get broken..is there a fast way to fix it?

2条回答
对你真心纯属浪费
2楼-- · 2019-08-02 21:22

If you want all your links to resolve to the root, you could do it server-side with:

<img src="~/apps/thisapp/images/logo.gif" alt="" runat="server" />

The combination of the root tilde operator ("~/") and the runat attribute will ensure server-side resolution of the link.

查看更多
Viruses.
3楼-- · 2019-08-02 21:22

There's probably not a good fast way to fix it without going through each relative URL. Generally, you'll want to use Url.Content.

<img src="<%= Url.Content("~/images/logo.gif") %>"/>
查看更多
登录 后发表回答