There is another approach that I read in some forums, to add an Image file (Image with Server Name) in the Web Application's specific URL path and hitting that URL opens the image of respective server. There is a problem with this if the server files get synced. Usually they does if they are behind the load balancer and with specific configuration, the Inetpub and Hive files get synced with latest files in other servers.
The other approach I feel is more reliable. Simple way. There are many other ways too by using WMI Scripting and using other server methods with elivated previllages. But the following is pretty simple.
1. Create a text file in each Server and save in a path. Say, C:\support\server.txt
Enter that particular server name in this text file
2. Create a server.aspx file with content as below.
<%@ Page Language="C#" %>
<html>
<head>
<title>Which Web Frontend Server (WFE) ?</title>
</head>
<body>
<%
System.IO.StreamReader sr = new System.IO.StreamReader("C:\\Support\\server.txt");
string line;
while(sr.Peek() != -1)
{
line = sr.ReadLine();
Response.Write(Server.HtmlEncode(line) + "<br/>");
}
%>
</body>
</html>
<html>
<head>
<title>Which Web Frontend Server (WFE) ?</title>
</head>
<body>
<%
System.IO.StreamReader sr = new System.IO.StreamReader("C:\\Support\\server.txt");
string line;
while(sr.Peek() != -1)
{
line = sr.ReadLine();
Response.Write(Server.HtmlEncode(line) + "<br/>");
}
%>
</body>
</html>
3. Make sure the web application, where you are going to upload this aspx file, has following entry in the web.config fiile.
Following line is to be added to the web.config file in the <SafeMode> tag.
<PageParserPaths>
<PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
</PageParserPaths>
other wise you will get the below error:
4. Then go to any Site Collection in the that Web Application, add aspx file you created, to any of Document Library, and then open the server.aspx file.
If everything works, then you will see the content in text file as below.
No comments:
Post a Comment