首页 > 开发 > 综合 > 正文

Online CPU Console using a Web Control Library wit

2024-07-21 02:16:43
字体:
来源:转载
供稿:网友
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 download
vw_process.aspx
call 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 download
vw_service.aspx
call 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 download
web.config
we 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 configuration
the 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
conclusion
our 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.
 
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表