Control.ResolveUrl versus Control.ResolveClientUrl versus VirtualPathUtility.ToAbsolute

前端 未结 4 512
無奈伤痛
無奈伤痛 2020-11-30 07:37

Is there any benifit to using one of these methods over the other when resolving paths which start with the tilde (~)?

Generally, what is a better practice, should y

4条回答
  •  时光说笑
    2020-11-30 08:21

    Note that VirtualPathUtility.ToAbsolute(virtualPath) will throw an exception if a query string is included in the path.

    The HttpException message will be along the lines of "'~/YourVirtualPath/YourPage.aspx?YourQueryStringArg=FooBar' is not a valid virtual path."

    See Rick Strahl's Web Log:ResolveUrl() without Page and MSDN: VirtualPathUtility.ToAbsolute Method (String)

提交回复
热议问题