Path - Raiz do site

<< Click to Display Table of Contents >>

Navigation:  ASP.NET > Dicas avançadas >

Path - Raiz do site

Previous pageReturn to chapter overviewNext page

Para saber se está rodando local ou na web

 

  if (HttpContext.Current.Request.IsLocal)

      lbInfo.Text = "rodando local!";

 

Request.Url Properties & Examples

 

Função

Resultado para

http://localhost:51348/WebForm1.aspx?id=10&ordem=nome

Resultado para

http://teste.market.com.br/WebForm1.aspx?id=10&ordem=nome

Request.Url.GetLeftPart(UriPartial.Authority)

http://localhost:51348

http://teste.market.com.br

Request.Url.GetLeftPart(UriPartial.Path)

http://localhost:51348/WebForm1.aspx

http://teste.market.com.br/WebForm1.aspx

Request.Url.GetLeftPart(UriPartial.Query)        

http://localhost:51348/WebForm1.aspx?id=10&ordem=nome

http://teste.market.com.br/WebForm1.aspx?id=10&ordem=nome

Request.Url.GetLeftPart(UriPartial.Scheme)

http://

http://

Request.Url.ToString

http://localhost:51348/WebForm1.aspx?id=10&ordem=nome

http://teste.market.com.br/WebForm1.aspx?id=10&ordem=nome

Request.Url.AbsolutePath

/WebForm1.aspx

/WebForm1.aspx

Request.Url.AbsoluteUri

http://localhost:51348/WebForm1.aspx?id=10&ordem=nome

http://teste.market.com.br/WebForm1.aspx?id=10&ordem=nome

Request.Url.Authority

localhost:51348

teste.market.com.br

Request.Url.GetComponents(UriComponents.AbsoluteUri, UriFormat.SafeUnescaped)

http://localhost:51348/WebForm1.aspx?id=10&ordem=nome

http://teste.market.com.br/WebForm1.aspx?id=10&ordem=nome

Request.Url.GetComponents(UriComponents.Host, UriFormat.SafeUnescaped)

localhost

teste.market.com.br

Request.Url.GetComponents(UriComponents.HostAndPort, UriFormat.SafeUnescaped)

localhost:51348

teste.market.com.br:80

Request.Url.GetComponents(UriComponents.HttpRequestUrl, UriFormat.SafeUnescaped)

http://localhost:51348/WebForm1.aspx?id=10&ordem=nome

http://teste.market.com.br/WebForm1.aspx?id=10&ordem=nome

Request.Url.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped)

WebForm1.aspx

WebForm1.aspx

Request.Url.GetComponents(UriComponents.PathAndQuery, UriFormat.SafeUnescaped)

/WebForm1.aspx?id=10&ordem=nome

/WebForm1.aspx?id=10&ordem=nome

Request.Url.GetComponents(UriComponents.Port, UriFormat.SafeUnescaped)

51348


Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped)

id=10&ordem=nome

id=10&ordem=nome

Request.Url.GetComponents(UriComponents.Scheme, UriFormat.SafeUnescaped)

http

http

Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped)

http://localhost:51348

http://teste.market.com.br

Request.Url.GetComponents(UriComponents.SerializationInfoString, UriFormat.SafeUnescaped)

http://localhost:51348/WebForm1.aspx?id=10&ordem=nome

http://teste.market.com.br/WebForm1.aspx?id=10&ordem=nome

Request.Url.GetComponents(UriComponents.StrongAuthority, UriFormat.SafeUnescaped)

localhost:51348

teste.market.com.br:80

Request.Url.GetComponents(UriComponents.StrongPort, UriFormat.SafeUnescaped)

51348

80

Request.Url.HostNameType.ToString

Dns

Dns

Request.Url.OriginalString

http://localhost:51348/WebForm1.aspx?id=10&ordem=nome

http://teste.market.com.br:80/WebForm1.aspx?id=10&ordem=nome