Get domain name

I am tryng to find the simplest way to get the domain name of the site that some code is running under, on the web I find this: 


Which always returns my server hostname... not what I want..

Ask One/Answer One.
11/13/2008 9:58:29 PM 93655 articles. 5 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 26

 maybe something like dis?

 string url = Request.Url.AbsolutePath;



my friends call me MOI
11/13/2008 10:04:07 PM

You can get the hostname from a HttpRequest, e.g.  Page.Request.Url.Host if you are executing in a aspx page.

The problem is that since the site may be running with several different host headers, eg, and, you cannot  be sure that next request will be wit same hostname.

You could query IIS for this information, but it may not solve the problem if the web site is the default site. If the site is the default site, the hostname can be any DNS alias/name that will point to this server or even the IP address of any of the network cards on the server.

Summary: there is no easy and reliable way for a site to determine all possible hostnames.

Andreas Paulsson
Software Developer
cimkey AB
11/13/2008 10:11:46 PM

Similar Artilces:

Implementing .Net Form into an web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

How Can I create Web Form To Search For Domain Name ?
HiHow Can I create Web Form To Search For Domain Name ?like www.Domain.comand thanks with my regardingC# ( pronounced as C-sharp ) is a new Java like language from Microsoft. Microsoft says that C# is a language with the power of C++ and simplicity of Visual Basic. C# supposed to be the best language for Microsoft's .NET programming Hi, Take a look @ WhoIs in ASP.NETHTHK B ShajudeenAreYaar.comDubai, United Arab Emirates. thanks for your replySorry it's not work .. I think the Company Stop the service regardsC# ( pronounced as C-sharp ) is a new Java like language fr...

How to get a changed web form control name to use in javascript?
When you use a user control, all web form controls names get changed by .NET some like ctl0_ctl5_txtFirstName where txtFirstName is the actual name I gave. in Javascript, to refer to this control I can do like document.getElementById('ctl0_ctl5_txtFirstName') but the thing is from time to time, the prefix, in this case ctl0_ctl5_, gets changed again. So the javascript does not work anymore. Is there any way of handling this situation? Is there any server method to get the prefix? If then I can send the prefix to client side and prefix it with actuall control name like var ...

getting start with and crystal repots(web form)
I use Crystal Report9 in Visual Studio.NET 2003..... Example at Northwind database I want a application that.....a form include a combobox that contain CustomerID.....If I choose one CustomerID and click OK button....a Report will display information about this Customer......I think that must use to do that ???? (How do I start to coding --please step by step or sample) please help me !!! Thank you so much!!! very good I have Dropdownlist when I choose the 'month'--> the all data of this field will show I use this Private Sub ddlMonth_Sel...

VB .net Web Form will not get contents of Text Box
I have created a web form with text boxes that are bound to a DataSet/DataView.  I have created button to navigate up and down the recordset.  That all works fine. I need to have the ability to edit/add text in any of the boxes and then when clicking "Save" button, it would build an UPDATE query to send to the database. When the Save button is clicked, I have coded to DIM a string var (strSQL) to use to build the SQL command.  For some reason, it will only get the text from a text box if the data was pulled the database.  If I add/edit data, then the SQL command will ha...

IN VS.Net how can i get a web form to scroll (design mode)
In design mode in VS.Net, there is a scroll bar next to the web form, but it is grayed out.  I can not figure out how to enable it.  I want to design a web form that is larger in size than the surface area shown in teh deisgn window.  Can someone help out with this?Thank you. VS design surface shows how the page is going to be rendered in the browser. Therefore, there is no 'virtual' large size. In the browser scroll bar appears if the browser window is smaller than the page content. You can make scroll bar to appear by enclosing page content in a large container e...

add/change name/delete server files via web form
I have the add(upload) part of this page figured out. I have an application with an "Images" sub directory. I know how to access the getfiles() method from the system.IO namespace. I am using a while loop to create a table with an edit button (so that you can change the name of the file) and a delete button so you can remove the file from the server. Each file is on a new line much like it would look if it was bound to a datalist or datagrid. Here is where I am clueless. Can anyone point me in the right direction? I am not looking for someone to write this for me, beca...

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Wor...

getting values from a web form to windows form
Hot Requirement ..... Is there any possible of getting values from a web form to windows form ????? Yes One way i to use the WebRequest and WebResponse classes of the System.Net namespace. For example:  WebRequest request = WebRequest.Create("URL of the web page); WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string content = reader.ReadLine(); ....    Reza Nassabehwww.professionalcsharp.comDon't forget to click "Mark as Answer" on the post that helped you. That way fut...

How get the name of form in <form> tags
i have a from in html tags <form id="Form1" method="post" runat="server"> </from> how get the name of form in code ??? thanx beginner ASP.NET Response.Write(Page.Controls(1).ID.ToString()) ? thank you a lotbeginner ASP.NET ...

Searching for a form name (present in a different web form)
Searching for a form name (present in a different web form) I have a web form (webform1) where all available forms are displayed. Another web form (webform2) where i have few or no alerts for one or each or none of the forms on the webform1. I have to place an icon or something to the next of the forms on webform1 to notify users about the alerts. What is the possible way to do this. Please give some suggestions. Thanks Hey, Not quite sure what you are looking for... could you explain in more depth, or post some code to help look at it? BrianBrian"Trust in the Lord and d...

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

ContextType.Domain gets PrincipalServerDownException unless specify domain controller by name
Hi There Just trying out the new System.DirectoryServices.AccountManagement with Visual Studio 2008 Express Edition.  My scenario:  -Client Windows XP joined to domain -One Windows Server 2003 domain controller / IIS  I want to get the full name of the logged in user. This works if I specify the domain controller name. Specifying the domain name (either fully qualified or NETBIOS) does not work. Any suggestions ? Am I doing something wrong here.   My working code is like this:   Dim domainContext As New System.DirectoryServices.AccountManagement.PrincipalCo...

Web resources about - Get domain name -

Domain name - Wikipedia, the free encyclopedia
A domain name is an identification string that defines a realm of administrative autonomy, authority, or control on the Internet . Domain names ...

Apple registers three car-related domain names, hinting at its electric vehicle project
... during media events while Tim Cook has resisted denying the project . The biggest tease to date comes in the form of new car-related domain ...

Apple registers a series of car-related domains
Apple registered three car-related domains in December, according to a recent report, potentially signaling the developing of the much-rumored ...

New domain registration sparks iCar chatter
You may not be able to buy an Apple Car yet, but an Apple Car website could be in the works.

Apple snaps up a trio of car-related web domains
... evidence is lending further weight to the possibility that we may one day cruise down the street in an Apple Car. Listings on domain search ...

NY Public Library releases 180,000 free public domain pictures
The New York Public Library has made 180,000 old-timey, out-of-copyright pictures available as high-res downloads through its Digital Collections ...

The Public Domain Once Again Loses In The New Year
... of every year under US Copyright Law, creative and scientific works that have reached the end of their copyright terms go into the public domain. ...

Anne Frank's Diary and Adolf Hitler's Mein Kampf Both Enter the Public Domain on Friday
A copyright fight is brewing in Europe this week as the deadline after which two key WWII-era texts will fall within the public domain steadily ...

Apple Just Called Dibs On A Few Car-Related Domain Names
... it happen eventually, and it we may just be getting closer to that day—in December, the company registered several car-related website domain ...

The New York Public Library Releases More Than 180,000 Digitized Items Into the Public Domain
The New York Public Library has released more than 180,000 digitized items into the public domain. Users can freely browse the digital collection ...

Resources last updated: 1/14/2016 6:51:57 PM