Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Get hostname & display on screen...

Posted on 2006-07-13
2
318 Views
Last Modified: 2012-06-21
I have some code which looks like this:
<%@ Register TagPrefix="SMWC" Namespace="SSWeb.Skins._controls" Assembly="SSWeb" %>
<%@ Page language="C#" Codebehind="Login.aspx.cs" AutoEventWireup="false" Inherits="SSWeb.Login" %>
<%@ Register TagPrefix="STWC" Namespace="SmarterTools.Web.Controls" Assembly="SmarterTools.Web" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <META name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
            <META name="CODE_LANGUAGE" content="C#">
            <META name="vs_defaultClientScript" content="JavaScript">
            <META name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
            <LINK href="Skins/_default/Skin.css" type="text/css" rel="stylesheet">
      </HEAD>
      <BODY>
            <form id="Form1" method="post" runat="server">
                  <ASP:TEXTBOX id="txtSiteID" runat="server" wrap="False" maxlength="250" width="200" columns="25"></ASP:TEXTBOX>
                  <!-- more ... //-->
            </form>
      </BODY>
</HTML>

Basically, I want the txtSiteID to have the address hostname, so if the address bar was showing this:
http://www.domain.tld/site.aspx

I would like the txtSiteID to have a value of:
'www.domain.tld'

As you can see this may not be stright forwards as I have some CodeBehind and Inherits, and I'm not 100% sure how this works with the current form. I also do not have access to it's code.
0
Comment
Question by:aproxity
2 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17100860
try this:

Dim hostname as String=Environment.MachineName
0
 
LVL 4

Accepted Solution

by:
svy earned 300 total points
ID: 17101123
use Request.Url.Host

MachineName can be different from actual HostName
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question