获取完整网址URL以波浪号(〜)符号 [英] Getting full URL from URL with tilde(~) sign

查看:1534
本文介绍了获取完整网址URL以波浪号(〜)符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得开始与波浪号(〜)一个典型的asp.net网址解析成一个完整准确的URL开始以http:

I am trying to get a typical asp.net url starting with the tilde sign ('~') to parse into a full exact url starting with "http:"

我有这个字符串〜/ PageB.aspx

I have this string "~/PageB.aspx"

,我想使之成为 http://myServer.com/PageB.aspx

我知道有几种方法来解析的网址,并获得服务器以及应用程序和这样的不同的路径。我尝试了好几种,但没有得到我想要的结果。

I know there is several methods to parse urls and get different paths of server and application and such. I have tried several but not gotten the result i want.

推荐答案

如果你在一个页面处理器是你总是可以使用 RESOLVEURL 方法转换的相对路径到一个服务器的特定的路径。但是如果你想在http://www.yourserver.se藏汉的一部分,你必须prePEND的 Request.Url.Scheme Request.Url.Authority 来了。

If you're in a page handler you could always use the ResolveUrl method to convert the relative path to a server specific path. But if you want the "http://www.yourserver.se" part aswell, you'll have to prepend the Request.Url.Scheme and Request.Url.Authority to it.

这篇关于获取完整网址URL以波浪号(〜)符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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