web
Call the event viewer control by the tag prefix colon and the class name of eventlog.cs. Note that we set a property from the query string in the code behind file.
Display vw_EventLog.aspx file < !-- Register the WROXControlLib Assembly -- >
<%@ Register TagPrefix="CPU" NameSpace="WROXCPUCONSOLE.ControlLib" Assembly="WROXControlLib" %>
<HTML>
<BODY>
<!-Call the Event Log Custom Control -->
<CPU:EventLog id="eventlog1"
runat="server"
Machine="machine">
</CPU:EventLog>
</BODY>
<HTML>
Code Behind vw_EventLog.aspx.cs file public class vw_EventLog : System.Web.UI.Page
{
//Event Log Custom Control
protected WROXCPUCONSOLE.ControlLib.eventlog eventlog1;
private void Page_Load(object sender, System.EventArgs e)
{
//Set the machine property from the Query String
eventlog1.Machine = Request.QueryString["machine"].ToString();
}
}
Event Log Application Available in the Code Downloadvw_Process.aspxCall the process panel control by the tag prefix colon and the class name of process.cs. Note that we set a property from the query string in the code behind file.
Display vw_Process.aspx file < !-- Register the WROXControlLib Assembly -- >
<%@ Register TagPrefix="CPU" NameSpace="WROXCPUCONSOLE.ControlLib" Assembly="WROXControlLib" %>
<HTML>
<BODY>
<!-Call the Process Custom Control -->
<CPU:PROCESS id="processes"
runat="server"
Machine="machine">
</CPU:PROCESS>
</BODY>
<HTML>
Code Behind vw_Process.aspx.cs file :public class vw_Process : System.Web.UI.Page
{
//Process Custom Control
protected WROXCPUCONSOLE.ControlLib.process processes;
private void Page_Load(object sender, System.EventArgs e)
{
//Set the machine property from the Query String
processes.Machine = Request.QueryString["machine"].ToString();
}
}
Process Panel Application Available in the Code Downloadvw_Service.aspxCall the service panel control by the tag prefix colon and the class name of services.cs. Note that we set a property from the query string in the code behind file.
Display .aspx file< !-- Register the WROXControlLib Assembly -- >
<%@ Register TagPrefix="CPU" NameSpace="WROXCPUCONSOLE.ControlLib" Assembly="WROXControlLib" %>
<HTML>
<BODY>
<!-Call the Service Custom Control -->
<CPU:SERVICES id="service"
runat="server"
Machine="machine">
</CPU:SERVICES>
</BODY>
<HTML>
Code Behind .aspx.cs file:public class vw_Service : System.Web.UI.Page
{
//Service Custom Control
protected WROXCPUCONSOLE.ControlLib.services service;
private void Page_Load(object sender, System.EventArgs e)
{
//Set the machine property from the Query String
service.Machine = Request.QueryString["machine"].ToString();
}
}
Service Panel Application Available in the Code DownloadWeb.configWe tie the CPU Console together using the web.config file; here security is set for the entire application and any assemblies this application will execute. We impersonate the client's identity to call the assemblies, which in turn uses the client's identity to call the event log, processes, and services on any machine the user has access rights to. By setting the authentication type to Windows, ASP.NET will automatically retrieve the username and password when the user logs in. Web.config file should contain the following elements.
<configuration>
<system.web>
<authentication mode="Windows" />
<identity impersonate="true" />
</system.web>
</configuration>
IIS ConfigurationThe final step is to configure IIS. In order to configure IIS correctly, and separate the release version and development versions, build the release version of our ASP.NET Web Application in the
Program Files folder instead of the
Inetpub folder.
Open Internet Services Manager, right-click on the
default web site. Choose
New | Virtual Directory. Click
Next, and enter an alias, such as
CPUConsoleApp (do not choose the same name of the ASP.NET Web Application). Browse to the ASP.NET Web Application that was moved out of
inetpub/wwwroot. Click
finish to complete the setup.
The new Virtual Directory will now be viewable; right-click and select
properties. Click
Directory Security | Edit. Uncheck all the boxes except for
Basic Authentication, and click the
Edit button besides
Basic Authentication. Type a backslash ("
/ ") in the
Domain text area. The backslash allows users of the console to control multiple domains. Click
OK on each of the three forms open to complete the configuration. Stop and start IIS to ensure proper configuration settings before viewing the application. Users must be in the group of administrators on the server and the machine they connect to.
IIS Authentication Configuration The Web Application will be viewable by opening Internet Explorer and typing the following URL into the address bar.
http://localhost/VirtualDirectory/ASP/vw_Default.aspx
If IIS is configured correctly, there will be a prompt to log in before entering the web application. Use a Windows 2000 Account Domain/UserName for the User Name input, and the password of the account.
Login Prompt on Entrance of the Web Application ConclusionOur completed online CPU Console is a multi-tiered, robust, reusable application that is easily modifiable, and serves an important business purpose. In the downloadable code, connect to the vw_default.aspx web form in the ASP folder to allow the user to select a machine name.
By using the Online CPU Console, one can easily administer services, events and processes of any machine, even those machines that are not .NET framework enabled.
mQrHTML5中文学习网 - HTML5先行者学习网mQrHTML5中文学习网 - HTML5先行者学习网