【解決方法】ホスト名を表示する古い会社のイントラネット リンクのヘルプ

プログラミングQA


そのため、Sharepoint への移行を待っている古い社内イントラネットがあります。 それまでの間、MIS/IT サポートを求める通常のスタッフが、イントラネット ページのリンクをクリックしてローカル コンピュータのホスト名を表示するのを簡単にしたいと考えました。 クリックするとすでにポップアップしてIPアドレスが表示されるものがありますが、私はホスト名の方が好きです. 現在のページは、javascript と ASP.net が混在して書かれています。 私はあまりコーダーではありませんが、いくつかのコードを見て理解し、小さな編集を行うことができます。 私は多くの調査を行いましたが、ページを現在の “GetIP.asp” ページと同じように動作させることはできません。 どんな助けでも大歓迎です。

現在の GetIP.asp は次のとおりです。

<!-- metadata type="typelib" file="c:\windows\system32\scrrun.dll" -->
<html>
<head>

<%
Dim UserIPAddress
UserIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If UserIPAddress = "" Then
  UserIPAddress = Request.ServerVariables("REMOTE_ADDR")
End If
%>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Computer IP Address</title>
<script language="JavaScript">
<!--
// This will resize the window when it is opened or
// refresh/reload is clicked to a width and height of 500 x 500
// with is placed first, height is placed second
window.resizeTo(500,150)
window.moveTo(350,300)
-->
</script>

<style type="text/css">

</style>

</head>
<body>
<center>
<h1 style="font-size:60";"face:Verdana">
<%
	Response.Write( UserIPAddress )
%>

</h1></center>
</body>
</html>

私が試したこと:

これは、ホスト名を表示するために機能させようとしたが機能しない GetHostname.asp です。

<!-- metadata type="typelib" file="c:\windows\system32\scrrun.dll" -->
<html>
<head>

<%
System.Net.IPHostEntry host;
host = System.Net.Dns.GetHostEntry(HttpContext.Current.Re quest.ServerVariable["REMOTE_HOST"]);
string strComputerName = host.HostName;
%>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>WKS/LTP Name</title>
<script language="JavaScript">
<!--
// This will resize the window when it is opened or
// refresh/reload is clicked to a width and height of 500 x 500
// with is placed first, height is placed second
window.resizeTo(500,150)
window.moveTo(350,300)
-->
</script>

<style type="text/css">

</style>

</head>
<body>
<center>
<h1 style="font-size:60";"face:Verdana">
<%
	Response.Write("WKS/LTP Name is: " + strComputerName); 
%>

</h1></center>
</body>
</html>

解決策 1

アン .asp ファイルは、昔ながらの「クラシック」ASP ページです。 組み込みツールがほとんどない古い言語である VBScript を実行します。

あなたのコード GetHostname.asp ファイルは C# です。 これは ASP.NET ページでのみ機能します。

ファイルの名前を次のように変更してみてください GetHostname.aspx 最初の行を置き換えます(<!-- metadata ... -->) と:

ASPX
<%@ Page Language="C#" %>

それが機能するかどうかは、サーバーに .NET Framework がインストールされているかどうか、および IIS サイトで “マネージド コード” が有効になっているかどうかによって異なります。 コードと同じくらい古いサーバーを使用している場合は、そうではない可能性があります。

コメント

タイトルとURLをコピーしました