ASP.NET and Current hostname and Port

In Silverlight Application it's possible to query current Application's
hostname and port using namespace Windows.System and code like
below

String hostname = Application.Current.Host.Source.Host + ":" +
Application.Current.Host.Source.Port;

I tried to find out how to do this in ASP.NET Application but couldn't
succeeded.
Does anyone know how to get same result in ASP.NET Applicatio?

Cheers,

JQ
John Q [ Mo, 14 April 2008 19:17 ] [ ID #1941907 ]

Re: ASP.NET and Current hostname and Port

re:
!> I tried to find out how to do this in ASP.NET Application but couldn't succeeded.
!> Does anyone know how to get same result in ASP.NET Applicatio?

Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim MyUrl As Uri = Request.Url
Dim fullappnameProtocolAndPort As String = "The full URL, protocol and port for the application is : " _
& Server.HtmlEncode(MyUrl.Scheme) & "://" & fullappname & ":" & port & Request.ApplicationPath & "/"

That code will also give you the correct protocol.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
======================================
"John Q" <john.q [at] mail.com> wrote in message news:fu031v$a8g$1 [at] nyytiset.pp.htv.fi...
> In Silverlight Application it's possible to query current Application's
> hostname and port using namespace Windows.System and code like
> below
>
> String hostname = Application.Current.Host.Source.Host + ":" + Application.Current.Host.Source.Port;
>
> I tried to find out how to do this in ASP.NET Application but couldn't succeeded.
> Does anyone know how to get same result in ASP.NET Applicatio?
>
> Cheers,
>
> JQ
>
>
nomailreplies [ Mo, 14 April 2008 20:22 ] [ ID #1941913 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » ASP.NET and Current hostname and Port

Vorheriges Thema: url rewriting and authentication
Nächstes Thema: Re: custom control designer & content pages