PerformanceCounter 获取服务器CPU 应该是权限问题。服务器是运营商的话,请他们帮你。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有出错的截图吗上传,不然都是瞎猜 放到page之前去运行就可以了using System;using System.IO;using System.Text.RegularExpressions;using System.Threading;using System.Web;using System.Xml;using Galsun.Common;using Galsun.HH.FCX.Content;using Galsun.HH.FCX.Mode;using System.Data;using System.Management;namespace Galsun.HH.FCX.Web.UI{ public class HttpModule : System.Web.IHttpModule { /// <summary> /// 实现接口的Init方法 /// </summary> /// <param name="context"></param> public void Init(HttpApplication context) { GetHardID(); } /// <summary> /// 获取硬盘ID /// </summary> /// <returns>硬盘ID</returns> public static string GetHardID() { string HDInfo = ""; ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive"); ManagementClass cimobject2 = new ManagementClass("Win32_Processor"); try { ManagementObjectCollection moc1 = cimobject1.GetInstances(); foreach (ManagementObject mo in moc1) { HDInfo += (string)mo.Properties["Model"].Value; break; } ManagementObjectCollection moc2 = cimobject2.GetInstances(); foreach (ManagementObject mo in moc2) { HDInfo += (string)mo.Properties["Processorid"].Value; break; } } catch (Exception err) { HDInfo = err.ToString(); } if (System.Web.HttpContext.Current.Application["HDInfo"] == null) { System.Web.HttpContext.Current.Application.Lock(); System.Web.HttpContext.Current.Application["HDInfo"] = HDInfo; System.Web.HttpContext.Current.Application.UnLock(); } return HDInfo; } public void Application_OnError(Object sender, EventArgs e) { HttpApplication application = (HttpApplication)sender; HttpContext context = application.Context; //if (context.Server.GetLastError().GetBaseException() is MyException) { //MyException ex = (MyException) context.Server.GetLastError().GetBaseException(); context.Response.Write("<html><body style=\"font-size:14px;\">"); context.Response.Write("GL.CMS Error:<br />"); context.Response.Write("<textarea name=\"errormessage\" style=\"width:80%; height:200px; word-break:break-all\">"); context.Response.Write(System.Web.HttpUtility.HtmlEncode(context.Server.GetLastError().ToString())); context.Response.Write("</textarea>"); context.Response.Write("</body></html>"); context.Response.End(); } } /// <summary> /// 实现接口的Dispose方法 /// </summary> public void Dispose() { } }}web.config <httpModules> <add type="Galsun.Easy.Web.UI.Base.HttpModule" name="HttpModule" /> </httpModules> .NET什么CMS比较好 <a></a>问题 如何给web gridview控件在编辑状态下哪个控件(如textbox)添加脚本事件(如onKeyDown)事件 【痛苦】UpdatePanel仍闪烁??? Session和全局变量互斥问题,急!在线等! !!!高手救命,是不是IIS配置出现了问题?? 请问如何在各种validator控件验证失败后,焦点定位到验证失败控件? vs2008 vs2005兼容问题 ASP.NET中如何显示样式复杂的EXCEL报表? 莫名其妙!aspx和cs代码分开写就有问题! C#上传excel文档,设定好固定的格式内容,将内容字段插入数据库中,怎么实现 求助.
using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using System.Web;
using System.Xml;
using Galsun.Common;
using Galsun.HH.FCX.Content;
using Galsun.HH.FCX.Mode;
using System.Data;
using System.Management;
namespace Galsun.HH.FCX.Web.UI
{
public class HttpModule : System.Web.IHttpModule
{
/// <summary>
/// 实现接口的Init方法
/// </summary>
/// <param name="context"></param>
public void Init(HttpApplication context)
{
GetHardID();
}
/// <summary>
/// 获取硬盘ID
/// </summary>
/// <returns>硬盘ID</returns>
public static string GetHardID()
{ string HDInfo = ""; ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive");
ManagementClass cimobject2 = new ManagementClass("Win32_Processor");
try
{ ManagementObjectCollection moc1 = cimobject1.GetInstances(); foreach (ManagementObject mo in moc1)
{ HDInfo += (string)mo.Properties["Model"].Value;
break;
}
ManagementObjectCollection moc2 = cimobject2.GetInstances(); foreach (ManagementObject mo in moc2)
{ HDInfo += (string)mo.Properties["Processorid"].Value;
break;
}
}
catch (Exception err)
{
HDInfo = err.ToString();
}
if (System.Web.HttpContext.Current.Application["HDInfo"] == null)
{
System.Web.HttpContext.Current.Application.Lock();
System.Web.HttpContext.Current.Application["HDInfo"] = HDInfo;
System.Web.HttpContext.Current.Application.UnLock();
}
return HDInfo; } public void Application_OnError(Object sender, EventArgs e)
{
HttpApplication application = (HttpApplication)sender;
HttpContext context = application.Context;
//if (context.Server.GetLastError().GetBaseException() is MyException)
{
//MyException ex = (MyException) context.Server.GetLastError().GetBaseException();
context.Response.Write("<html><body style=\"font-size:14px;\">");
context.Response.Write("GL.CMS Error:<br />");
context.Response.Write("<textarea name=\"errormessage\" style=\"width:80%; height:200px; word-break:break-all\">");
context.Response.Write(System.Web.HttpUtility.HtmlEncode(context.Server.GetLastError().ToString()));
context.Response.Write("</textarea>");
context.Response.Write("</body></html>");
context.Response.End();
} }
/// <summary>
/// 实现接口的Dispose方法
/// </summary>
public void Dispose()
{ }
}
}
web.config
<httpModules>
<add type="Galsun.Easy.Web.UI.Base.HttpModule" name="HttpModule" />
</httpModules>