Get Host Name

I use this line of code to get the host name from a system:

 

System.Net.IPHostEntry obj = new IPHostEntry();
obj = Dns.GetHostByName(Request.UserHostAddress);
String HostName = obj.HostName.ToString();

and this retrieves this Host Name: bea-som.corp.bea.org

 

However from my client application I call this:

 System.Net.Dns.GetHostName()

and this retrieves the host name as: bea-som

 

What changes do I make to either the C# client application or website so that both of them take the same host name ?


Dont forget to click "Mark as Answer" on the post that helped you.
This credits the member,earns you a point & marks your thread as Resolved so that new users will know where to search for their queries.
0
som
6/12/2008 8:55:25 AM
asp.net.getting-started 91979 articles. 3 followers. Follow

4 Replies
414 Views

Similar Articles

[PageSpeed] 41

hello dear

Try this

Dim strVal As String = Request.ServerVariables("HTTP_HOST") 


======================================
Regard,
Pradeep Sahoo
Team Leader
Don't forget to click "Mark as Answer" on the post that helped you.
0
pradeepsahoo
6/12/2008 9:01:25 AM
pradeepsahoo:

hello dear

Try this

Dim strVal As String = Request.ServerVariables("HTTP_HOST") 

 

 

'System.Web.HttpRequest.ServerVariables' cannot be used like a method.

 

This is the error if I use your line of code:

String str = Request.ServerVariables("HTTP_HOST");


Dont forget to click "Mark as Answer" on the post that helped you.
This credits the member,earns you a point & marks your thread as Resolved so that new users will know where to search for their queries.
0
som
6/12/2008 9:20:19 AM

 

1) Dim myHost As String = System.Net.Dns.GetHostName

2) Dim myIPs As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(myHost)

myIPs.HostName

3)  Dim objIPHostEntry As IPHostEntry
  objIPHostEntry = Dns.GetHostByAddress( txtIP.Text )
  lblHostName.Text = objIPHostEntry.HostName  


 



View Blog

linkedin Asp.net Group

Don't forget to click “Mark as Answer” on the post that helped you
0
sameer_khanjit
6/12/2008 9:48:46 AM

Hi,

 

'System.Web.HttpRequest.ServerVariables' cannot be used like a method.

This is the error if I use your line of code:

String str = Request.ServerVariables("HTTP_HOST");

The code you are using is C#, and the simple is VB.NET.

Please try to using string str =  Request.ServerVariables["HTTP_HOST"];

 

I hope this helps.

 


Thomas Sun
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
Thomas
6/16/2008 7:13:23 AM
Reply:

Similar Artilces:

POST GET GET GET GET... WTH?
Hi, I'm at a loss to explain this... I have an ASPX page that I can't always navigate to. When I developed the app (it's Starter Kit Portal-based), I did it on my LAN and have had no trouble accessing the page. However, upon deployment, I see the following behavior: 1. POST request goes out looking for MyForm.aspx 2. GET request for MyForm.aspx 3. GET request for MyForm.aspx 4. ... X. GET request Sometimes, the page finally loads. Other times, it just ends up blank. Many times, it doesn't load at ALL the first POST - I just get a "The pa...

using relay-host.secureserver.net & getting email on gmail and yahoo account but not getting it on my godaddy account
using smtp server address as relay-host.secureserver.net getting email on gmail and yahoo account but not getting it on my godaddy account. Please help me out, ...

trying to get started and i am getting this error
when i go to http://www.porkchopsplayground.com, i get: DotNetNuke Upgrade Error The Assembly Version ( [ASSEMBLYVERSION] ) does not match the Database Version ( [DATABASEVERSION] ) ERROR: Could not connect to database. Could not find file 'd:\hosting\nmoran26\Providers\DataProviders\AccessDataProvider\DotNetNuke.mdb'. Any suggestions will be appreciated. Thanks, Nicole Do you have a username and password set on your database? Make sure you follow the steps mentionned in the Readme.txt located in the documentation folder. In any case make sure your credentials for yo...

Getting Start With .net
hi i'm intersted to learn asp.net (vb or delphi) . i programming with delphi6 but i'd like to tp know something about programming in internet specially with .net . i hear about microsoft.net with delphi 7 that i can programming with delphi in .net .... is it right ? what 's our opinian about it ? and better to learn Vb.Net or continu with delphi(or delphi.net) thanks. Ali Darabian I think there is some support for Delphi in .Net. However, you will find much more support from the user community if you choose a more popular language such as VB.Net or C#. Since your al...

how to get start with .NET
the net help people installed  to my desktop 1-microsoft visual studio .NET enterprise developer 2003 2-microsoft .NET framework 1.1 what else do i need ...???  and how can i try with some simple code in VS.Net and run it to see wat happen...????? please help If you want to develope web applications, then you'll also need IIS on your PC.  That'll require XP-Professional or Windows 2000/2003, but XP-Home edition won't allow IIS installation. As for how to get started, you can search the web for some tutorials or buy a good book on VS.  The topic is way too vast to...

get rid of that ridiculous getting started bookmark
Name: DOCTOR Product: Firefox Summary: get rid of that ridiculous getting started bookmark Comments: Browser Details: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

getting started in VS2005 C# which book should I get
Hello, I am getting started with VS2005, I have use VS2003 but not very much -(I did 4 small applications in it),  I am wondering which book you would recommend to learn the new features of VS2005, while learning more of C# programing in general There some links to good books in this thread i posted : http://forums.asp.net/thread/1489422.aspx Also these two make good reference material  Professional Visual Studio 2005 (Programmer to Programmer)   Microsoft Visual Studio 2005 Unleashed  So far I recommend Wrox's C# 2005  Read the beginning chap...

Getting error in Net::SFTP with get function
------=_Part_7028_3315294.1193837808284 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi All, I have the following code as part of my program; print "---=========> $file, $localFile\n"; $sftp -> get( $file, $localFile ) || warn("errrrr0rrrrr _---> $!".$sftp->status."\n");^M Even though it has downloaded the file properly, it is giving the following message: ---=========> /trading/tiscrdenhlist10310000.txt.old, /export/home/crdadm/rajeev/tiscrdenhlist103...

Where to start and how did you get started?
Hi, I have had a feeling for a long time to jump into the adds market for some time due to my low income (shooting for the stars) and I don't have anything better to do these days. But I find it really difficult not to give up due to lack of guides (what I can find atleast) and all the hard words which only makes me confused. But I won't give up. Never. Not sure if this is the right place to post this, but I deffinitly would be really greatfull for help getting started. How did you get started? +If there are any teacher that wanna show me the ropes private, I can give payment with ...

How to get host name in aspx
How to get this part only? mysite.com. I do not want to get the subdomain part (example mysubdomain.mysite.com). Here is my existing hard coded link: <asp:HyperLink ID="UserHyperLink" runat="server" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "Username") + "mysite.com" + %>'Rafal Zikbay.com - Free Classifieds (Search Over 5 mln jobs on Zikbay.com) DNN Direct You can get the full Host from Request.Url.  By splitting that string apart on the periods, you can keep those pieces you are interested in.  For example:D...

Getting Error when getting Excel work sheet name.
Hi all,I am using following code to get excel work sheet name.Getting the following error.It is working properly in Local machine.But when we upload in server it is giving following error. Cannot create ActiveX component. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Exception: Cannot create ActiveX component. and my source code  Imports Microsoft.Office.Interop.Excel    Dim objExcel As Exce...

Problem Getting Started
In have run the 1317set.bat file and still get the following error: Unable to get your db version please run version script against your db and restart your web application (go to update/scripts/ folder and run 1317set.bat). Any help to get me started would be much appreciated.www.creativenrg.co.uk | www.therivercard.com Have you checked your connection string? This is sometimes caused by a faulty db connection. I am new to Rainbow and get the same error when trying to run it for the first time. Does not matter which of the following I comment out in web.config: <!-...

Get Host Name in PD
Is there a way to get the web server host name from within PowerDynamo using a Netscape server? GetServerVariable("SERVER_NAME") only works with IIS. The reason I need it is I have a page, located at http://10.0.0.12/test/index.htm and on it I have a link to https://10.0.0.12/test/login.htm. Notice that the link is to https. The problem is that is an internal IP address, it can also be accessed from an external IP address from outside the firewall. Also, as we move to production, I would rather not have to change code, if possible. Any ideas on how to construct "...

How do I get started with AJAX.Net?
Hi All, I'm a seasoned asp.net developer but have not yet ventured into atlas et al.  I prefer books, but will take whatever I can get if it's good and will get me going. Any recommendations? Thx in advance. Jeff try here first http://ajax.asp.net/downloads/default.aspx?tabid=47 then learn from sample and docJames Wu (MIB426).NET is only way to goMCP, MCSE, MCDBA, MCSD, MCAD I find the materials online display features and implementations but are lacking architectural depth, and am seeking more comprehensive resources. By architectural depth, I mean that I cannot watch ...

Web resources about - Get Host Name - asp.net.getting-started

Host - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Australian Survivor host rumour — is Dr Chris Brown in the running?
IT’S months until filming begins on Ten’s version of Survivor , but rumours are already swirling about who’ll host the big-budget show.

Marvell Implements Host Memory Buffer for DRAM-less 88NV1140 SSD Controller
... one feature introduced in the NVMe 1.2 revision has been picked up by a controller that will likely see use in the consumer space. The Host ...

Social media calls for Schumer, Lawrence to host next year's Globes
"In all seriousness," the BFFs were "thrilled" to be onstage together will we be seeing them again next year?

AirBNB Will Gently Nag Hosts In San Francisco Instead Of Requiring City Registration
Airbnb’s hometown of San Francisco voted down a proposition that would have limited the number of days per year that a host on the service can ...

CBS Host Corners Paul Ryan Over Latest Obamacare Repeal Vote: 'How Is That An Alternative?'
... efforts to undermine the Affordable Care Act. "You said that you wanted the Republicans to offer an alternative to the president," CBS host ...

MSNBC Host: SOTU Is Bring Your Muslim To Work Day For Democrats
Similar to 'bring our daughters to work day, bring our children to work day'

Jane Fonda Will Host Comedy Night As Political Fundraiser
... Fonda , enjoying a resurgence on TV ( Grace And Frankie , The Newsroom ) and the big screen ( Youth , This Is Where I Leave You ) will host ...

Jimmy Fallon, Stephen Colbert & Other Late-Night Hosts Pay Tribute to David Bowie
Jimmy Fallon, Stephen Colbert & Other Late-Night Hosts Pay Tribute to David Bowie

Golden Globes Host Ricky Gervais Targets Sean Penn, Hollywood Pay Gap, 'The Martian'
Golden Globes Host Ricky Gervais Targets Sean Penn, Hollywood Pay Gap, 'The Martian'

Resources last updated: 1/12/2016 6:24:02 PM