开发者

Links in master page with tilde URLs give 404 depending on the page

I have a master page with links to other pages in the site. Those links use tilde paths (like "~/dir1/page2.aspx"). On most of the pages in开发者_C百科 the site that use this master page, there is no problem.

The problem only occurs on a few pages that use the master page. The links are VERY wrong; it tries to use the ~ as part of the link (so they are "http://server.domain.com/~/dir1/page2.aspx").

It's as if it is treating the tilde as a literal under certain circumstances.


Sounds like you're not properly resolving the URLs.

Are you writing ResolveUrl("~/")?

Also make sure that if you use ~/ that your controls are runat="server".


I just had this issue and the answer that worked best for me was to use the asp:Hyperlink control:

<asp:HyperLink ImageUrl="/Images/Logo.PNG" runat=server NavigateUrl="~/Default.aspx" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜