在asp.net路径中使用代字号(〜) [英] use of tilde (~) in asp.net path

查看:303
本文介绍了在asp.net路径中使用代字号(〜)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个asp.net AP,而这个链接不工作在IE浏览器而不是在FF。

i'm working on an asp.net ap, and this link does work in IE but not in FF.

<a href="~/BusinessOrderInfo/page.aspx" >

但我想知道,是不是波浪号的东西,只能在asp.net服务器控件使用,然后将实际的路径被取代?

but i was wondering, isn't the tilde something that can only be used in asp.net server controls, and will then be replaced by the actual path?

是否有可能使用波浪号的一个标签,然后这是什么意思?

Is it possible to use the tilde in a a-tag, and what then does it mean?

顺便说一句,当我在根是,该链接的作品

by the way, when i'm in the root, the link works

www.myserver.com/default.aspx, click the link, ok!

www.myserver.com/otherpart/default.aspx, click the link, not ok!

它创造这样的:

www.myserver.com/otherpart/~BusinessOrderInfo/page.aspx

这是设计? (我想知道,因为我有幸来修复这个bug(如果它是一个): - ))

is this by design? (i want to know, because i have the privilege to fix this bug (if it is one) :-))

推荐答案

您是正确的,它只能在服务器控件。你有这些基本选项:

You are correct, it only works in server controls. You've got these basic options:

更改为超链接来作为的 Web控件

<asp:HyperLink NavigateUrl="~/BusinessOrderInfo/page.aspx" Text="Whatever" runat="server" />

或者,运行在服务器端锚作为的 HTML控制的:

<a href="~/BusinessOrderInfo/page.aspx" runat="server" >

或者使用 Page.ResolveUrl

<a href="<%= Page.ResolveUrl("~/BusinessOrderInfo/page.aspx") %>">...</a>

这篇关于在asp.net路径中使用代字号(〜)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆