在ASP.NET中创建自定义URL令牌(如MOSS) [英] Creating custom URL tokens in ASP.NET (a la MOSS)
问题描述
在ASP.NET中,波浪号(〜)被视为URL中的令牌,并将以该前缀为前缀的路径视为相对于应用程序根目录的路径.这是众所周知的功能.
In ASP.NET, the tilde (~) is treated as a token in URLs and treats paths prefixed with that as relative to the application root. This is well-known functionality.
在MOSS中,还有其他标记,例如〜sitecollection/mypath ...,它们的行为类似,但是将路径视为相对于网站集根目录的路径.这是如何完成的?经过粗略的搜索后,我找不到有关如何向.NET URL解析机制添加此类令牌的任何信息.
In MOSS, there are other tokens, such as ~sitecollection/mypath... which behaves in a similar way, but treats the path as relative to the site collection root. How is this accomplished? After a cursory search I could not find any info on how to add tokens like this to the .NET URL resolution mechanism.
推荐答案
它可能不是唯一的地方,但是 SPUrlExpressionBuilder 来进行声明使用:
It may not be the only place, but SPUtility.GetServerRelativeUrlFromPrefixedUrl() will parse URLs with ~site and ~sitecollection. MOSS also provides SPUrlExpressionBuilder for declarative use:
<link runat="server" rel="stylesheet" type="text/css"
href="<% $SPUrl:~SiteCollection/Style Library/MyStyles/style.css %>" />
这篇关于在ASP.NET中创建自定义URL令牌(如MOSS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!