2

How do I get my full computer name (with domain) to show up in a url I'm constructing in my code?

Updated:

Ok so how do I utilize

System.Net.Dns.GetHostByName("localhost").HostName 

with existing

String myUrl = Url.Action("MyAction", "MyController", new { id = id }, "http");

to have the FQDN in my link on my page

Rod
  • 14,529
  • 31
  • 118
  • 230
  • 1
    Can you give an example? I don't know what you are trying to accomplish. – Cody Gray - on strike Feb 03 '11 at 13:49
  • 1
    Have a look here: http://stackoverflow.com/questions/804700/does-anyone-know-a-way-to-get-the-fqdn-of-local-machine-in-c – Adrian Fâciu Feb 03 '11 at 13:50
  • 1
    You could have multiple FQNs (Fully Qualified Names) for a single machine so this is not straight-forward. I take it you want the DNS name for the machine? – Tim Lloyd Feb 03 '11 at 13:50
  • @chibacity - the DNS name sounds right I guess – Rod Feb 03 '11 at 14:54
  • @Cody Gray - I want to display a link on my page so a user can click on it but the link must have the dns included as part of the host name – Rod Feb 03 '11 at 14:56
  • again, what do you actually want? There's plenty of functions that return absolute url, relative url, then there's IIS bindings and Netbios name, etc. If It's FQDN, why don't you accept the answer below? – mare Feb 03 '11 at 23:15
  • All I want to do is put a link in an email that a user can click on, but I need the link to have the full domain name and the port number included, how do I do that? – Rod Feb 16 '11 at 15:20

1 Answers1

0

I'm with Cody inasmuch as I'm not properly sure how you're trying to achieve what you want to, however, banking on the fact that you know this stuff then maybe we can be somewhat removed from the context of the practice and offer solutions for your to integrate, on such a basis, here is a thread which ought to interest you...

How to find FQDN of local machine in C#/.NET ?

Community
  • 1
  • 1
Grant Thomas
  • 44,454
  • 10
  • 85
  • 129