469,269 Members | 1,006 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,269 developers. It's quick & easy.

Getting domain from request

Hello.

I'm running my web application at "http://www.mysite.com/MyForm.aspx".
Now I want to get from the request of "MyForm.aspx" web domain of the site
(http://www.mysite.com/).
How can I get it?

Thank you.
Nov 19 '05 #1
3 6264
AF
> Hello.
I'm running my web application at "http://www.mysite.com/MyForm.aspx".
Now I want to get from the request of "MyForm.aspx" web domain of the site
(http://www.mysite.com/).
How can I get it?
Thank you.


Hello David,

The "Request" instance can answer your question. Many parts are available such
as :
Request.Url
Request.Url.*
Request.UserAgent
... and so on...

Antonio
http://www.futureblogs.net/antonio
Nov 19 '05 #2
Use Request.Uri.GetLeftPart(UriPartial.Authority) . Or
UriPartial.Something else.

Grtz, Wouter vanVugt
blogs.infosupport.com/wouterv

Nov 19 '05 #3
Absolutely correct, although there's a couple of gotchas to watch out for.

Dim Url1 As String = Request.Url.ToString
Dim FQDN As New Uri(Url1)
Dim dns As String
dns = FQDN.GetLeftPart(UriPartial.Authority)

Of course, if only the raw domain name is wanted, use :
Dim dnsname As String = Request.Url.Host

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/
======================================
<wo******@hotmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Use Request.Uri.GetLeftPart(UriPartial.Authority) . Or
UriPartial.Something else.

Grtz, Wouter vanVugt
blogs.infosupport.com/wouterv

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by BluaP | last post: by
1 post views Thread by Brian 5 | last post: by
2 posts views Thread by Rob Nicholson | last post: by
3 posts views Thread by Joshua Morgan | last post: by
13 posts views Thread by trpost | last post: by
1 post views Thread by David C | last post: by
1 post views Thread by Jens | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.