自从这个页面放到服务器上后 w3wp.exe,的CPU占用很不稳定,基本上是在20-90之间波动
public partial class VV_Default : System.Web.UI.Page
{
static Object lockObject = new Object();
protected void Page_Load(object sender, EventArgs e)
{
WriteLog();
}
private void WriteLog()
{
string id = Request.QueryString["id"];
if (id == null || id == string.Empty)
{
id = "null";
}
string FilePath = Server.MapPath("../files/index_" + id + "_log.txt");
string from = "null";
if (Request.UrlReferrer != null)
{
from = Request.UrlReferrer.AbsoluteUri;
}
lock (lockObject)
{
using (FileStream stream = new FileStream(FilePath, FileMode.Append, FileAccess.Write))
{
StreamWriter writer = new StreamWriter(stream, System.Text.Encoding.UTF8);
writer.WriteLine(DateTime.Now.ToString() + "\t" + from + "\t" + Request.UserHostAddress);
writer.Close();
}
}
}
}
public partial class VV_Default : System.Web.UI.Page
{
static Object lockObject = new Object();
protected void Page_Load(object sender, EventArgs e)
{
WriteLog();
}
private void WriteLog()
{
string id = Request.QueryString["id"];
if (id == null || id == string.Empty)
{
id = "null";
}
string FilePath = Server.MapPath("../files/index_" + id + "_log.txt");
string from = "null";
if (Request.UrlReferrer != null)
{
from = Request.UrlReferrer.AbsoluteUri;
}
lock (lockObject)
{
using (FileStream stream = new FileStream(FilePath, FileMode.Append, FileAccess.Write))
{
StreamWriter writer = new StreamWriter(stream, System.Text.Encoding.UTF8);
writer.WriteLine(DateTime.Now.ToString() + "\t" + from + "\t" + Request.UserHostAddress);
writer.Close();
}
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货