title: Get hostname in ASP.Net on IIS
body: <p>Based on my question <a href="https://stackoverflow.com/questions/47968440/get-hostname-in-wcf-on-iis">here</a></p>
  
  <p>I am going to get the hostname in <code>Application_Start</code> so I have done it before something like:</p>
  
  <pre><code>if(string.IsNullOrWhiteSpace(Hostname)) 
          Hostname = Dns.GetHostName();
  </code></pre>
  
  <p>Based on this screenshot:</p>
  
  <p><a href="https://i.stack.imgur.com/QUdeA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QUdeA.png" alt="enter image description here"></a></p>
  
  <p>But it returns <code>skyweb</code> - but I want to get <code>RND1</code>.</p>
  
  <p>The other solution to get hostname is <code>HttpContext.Current.Request.Url.Host;</code> but as you know I don't want get in through the pages event it is better be initiated at first go...</p>
  
  <p>So what is the best way to do this?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>Edit1:</strong></p>
  
  <p>If you take a look at <a href="https://stackoverflow.com/questions/47968440/get-hostname-in-wcf-on-iis">here</a> you will see what I am looking for which pointed in picture, meanwhile I mentioned in this screenshot again:</p>
  
  <p><a href="https://i.stack.imgur.com/rjGac.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rjGac.png" alt="enter image description here"></a></p>
  
  <p>I can't set this in configuration, It may be set while installing process or be set by admin of server manually.</p>
  
  <p>I am looking for hostname while be set in adding new website.</p>