获取页面的绝对URL [英] Obtaining the Absolute URL of a page

查看:121
本文介绍了获取页面的绝对URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站中有一个页面,我需要绝对的网址。在.NET中是否有一个

函数可以传递一个相对的url或者诸如

"〜/ mydirectory / mypage.aspx"哪个会返回一个绝对的网址?我需要这个

,因为目前我不知道该域名是什么(或者如果网站的子目录中存在

的可能性)该网站将在哪里

最终存在。此外,这将使开发过程中更容易测试。

我需要绝对网址,因为它将作为电子邮件的一部分发送。

谢谢。


Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

I have a page in my site that I need the absolute url of. Is there a
function in .NET to which you can pass a relative url or something such as
"~/mydirectory/mypage.aspx" which will return an absolute url? I need this
because at the moment I do not know what the domain name (or if there is the
possibility of the site going in a subdirectory) where the site will
eventually exist. Also, this will make it easier to test during development.
I need the absolute url because it will be getting sent as part of an email.
Thanks.

Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

推荐答案

Request.Url有帮助吗?


Kalpesh


9月8日上午10:50 *,Nathan Sokalski < nsokal ... @ kyledavidgroup.com>

写道:
Does Request.Url help?

Kalpesh

On Sep 8, 10:50*am, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
wrote:

我的网站中有一个页面,我需要绝对的网址的。在.NET中是否有一个

函数可以传递一个相对的url或者诸如

"〜/ mydirectory / mypage.aspx"哪个会返回一个绝对的网址?我需要这个

,因为目前我不知道该域名是什么(或者如果网站的子目录中存在

的可能性)该网站将在哪里

最终存在。此外,这将使开发过程中更容易测试。

我需要绝对网址,因为它将作为电子邮件的一部分发送。

谢谢。


Nathan Sokalski

njsokal ... @ hotmail.comhttp://www.nathansokalski.com/
I have a page in my site that I need the absolute url of. Is there a
function in .NET to which you can pass a relative url or something such as
"~/mydirectory/mypage.aspx" which will return an absolute url? I need this
because at the moment I do not know what the domain name (or if there is the
possibility of the site going in a subdirectory) where the site will
eventually exist. Also, this will make it easier to test during development.
I need the absolute url because it will be getting sent as part of an email.
Thanks.

Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/


9月8日,1:50 * pm,Nathan Sokalski < nsokal ... @ kyledavidgroup.com>

写道:
On Sep 8, 1:50*pm, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
wrote:

我的网站中有一个页面,我需要绝对的网址的。在.NET中是否有一个

函数可以传递一个相对的url或者诸如

"〜/ mydirectory / mypage.aspx"哪个会返回一个绝对的网址?我需要这个

,因为目前我不知道该域名是什么(或者如果网站的子目录中存在

的可能性)该网站将在哪里

最终存在。此外,这将使开发过程中更容易测试。

我需要绝对网址,因为它将作为电子邮件的一部分发送。

谢谢。


Nathan Sokalski

njsokal ... @ hotmail.comhttp://www.nathansokalski.com/
I have a page in my site that I need the absolute url of. Is there a
function in .NET to which you can pass a relative url or something such as
"~/mydirectory/mypage.aspx" which will return an absolute url? I need this
because at the moment I do not know what the domain name (or if there is the
possibility of the site going in a subdirectory) where the site will
eventually exist. Also, this will make it easier to test during development.
I need the absolute url because it will be getting sent as part of an email.
Thanks.

Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/



您可以使用

Request.Url.AbsoluteUri获取当前的绝对URL。你必须将当前相对网址不同的部分修改为你想要返回的部分。

You can get your current absolute URL by using
Request.Url.AbsoluteUri. you will have to modify the part different
from the current relative url to the one that you want to return.


否,我正在寻找一个函数,它将获得一个页面的绝对URL

,而不是我目前所在的页面。我想避免使用

字符串操作,这对于请求

对象中的任何内容都是必需的。还有其他想法吗?


" Kalpesh" < sh ********* @ gmail.com写信息

新闻:1b ********************* ************* @ z66g2000 hsc.googlegroups.com ...

Request.Url有帮助吗?


Kalpesh


9月8日上午10点50分,Nathan Sokalski < nsokal ... @ kyledavidgroup.com>

写道:
No, I am looking for a function that will get me the absolute URL of a page
other than the page I am currently on. I want to avoid the need to use
string manipulation, which would be required with anything in the Request
object. Any other ideas?

"Kalpesh" <sh*********@gmail.comwrote in message
news:1b**********************************@z66g2000 hsc.googlegroups.com...
Does Request.Url help?

Kalpesh

On Sep 8, 10:50 am, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
wrote:

我的网站中有一个页面,我需要绝对的网址的。在.NET中是否有一个

函数可以传递一个相对的url或者诸如

"〜/ mydirectory / mypage.aspx"哪个会返回一个绝对的网址?我需要这个

因为目前我不知道域名是什么(或者如果有



网站的可能性在一个子目录中,网站将最终存在
。此外,这将使在

开发期间更容易测试。

我需要绝对网址,因为它将作为
$ b $的一部分发送b电子邮件。

谢谢。


Nathan Sokalski

njsokal ... @ hotmail.comhttp://www.nathansokalski。 com /
I have a page in my site that I need the absolute url of. Is there a
function in .NET to which you can pass a relative url or something such as
"~/mydirectory/mypage.aspx" which will return an absolute url? I need this
because at the moment I do not know what the domain name (or if there is
the
possibility of the site going in a subdirectory) where the site will
eventually exist. Also, this will make it easier to test during
development.
I need the absolute url because it will be getting sent as part of an
email.
Thanks.

Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/



这篇关于获取页面的绝对URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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