using System; using System.Web; using System.IO; namespace Common { /// summary /// ExceptionLog 的摘要说明。 /// /summary public class ExceptionLog : ApplicationException { public ExceptionLog(string message) : base(message) { Init(); Log
using System;
using System.Web;
using System.IO;
namespace Common
{
///
/// ExceptionLog 的摘要说明。
///
public class ExceptionLog : ApplicationException
{
public ExceptionLog(string message)
: base(message)
{
Init();
Log();
}
public ExceptionLog(Exception inner)
{
ex = inner;
Init();
Log();
}
public Exception ex = null;
public override string Message
{
get
{
string msg = base.Message;
if (ex != null)
{
msg = ex.Message;
}
return msg;
}
}
string username = string.Empty;
public string UserName
{
get
{
return username;
}
set
{
username = value;
}
}
string userAgent = string.Empty;
public string UserAgent
{
get
{
return userAgent;
}
set
{
userAgent = value;
}
}
string ipAddress = string.Empty;
public string IPAddress
{
get
{
return ipAddress;
}
set
{
ipAddress = value;
}
}
string httpReferrer = string.Empty;
public string HttpReferrer
{
get
{
return httpReferrer;
}
set
{
httpReferrer = value;
}
}
string httpVerb = string.Empty;
public string HttpVerb
{
get
{
return httpVerb;
}
set
{
httpVerb = value;
}
}
string httpPathAndQuery = string.Empty;
public string HttpPathAndQuery
{
get
{
return httpPathAndQuery;
}
set
{
httpPathAndQuery = value;
}
}
DateTime dateCreated;
public DateTime DateCreated
{
get
{
return dateCreated;
}
set
{
dateCreated = value;
}
}
void Init()
{
DateCreated = DateTime.Now;
if (HttpContext.Current.Request.UrlReferrer != null)
httpReferrer = HttpContext.Current.Request.UrlReferrer.ToString();
if (HttpContext.Current.Request.UserAgent != null)
userAgent = HttpContext.Current.Request.UserAgent;
if (HttpContext.Current.Request.UserHostAddress != null)
ipAddress = HttpContext.Current.Request.UserHostAddress;
try
{
if (HttpContext.Current.Request != null
&& HttpContext.Current.Request.RequestType != null)
httpVerb = HttpContext.Current.Request.RequestType;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
if (HttpContext.Current.Request != null
&& HttpContext.Current.Request.Url != null
&& HttpContext.Current.Request.Url.PathAndQuery != null)
httpPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery;
if (HttpContext.Current.Request != null
&& HttpContext.Current.Request.UrlReferrer != null
&& HttpContext.Current.Request.Url.PathAndQuery != null)
httpReferrer = HttpContext.Current.Request.UrlReferrer.ToString();
}
public void Log()
{
string LogName = DateTime.Now.ToShortDateString() + ".txt";
string FilePath = HttpContext.Current.Request.PhysicalApplicationPath + "//Log//" + LogName;
if (!File.Exists(FilePath))
{
using (StreamWriter sw = File.CreateText(FilePath))
{
sw.WriteLine("Fields :Value");
sw.WriteLine();
}
}
using (StreamWriter sw = File.AppendText(FilePath))
{
sw.WriteLine("======================================");
sw.WriteLine("DateTime :" + this.DateCreated);
sw.WriteLine("Message :" + this.Message);
sw.WriteLine("IPAddress :" + this.IPAddress);
sw.WriteLine("HttpReferrer :" + this.HttpReferrer);
sw.WriteLine("HttpVerb :" + this.HttpVerb);
sw.WriteLine("HttpPathAndQuery :" + this.HttpPathAndQuery);
sw.WriteLine("UserName :" + this.UserName);
sw.WriteLine("UserAgent :" + this.UserAgent);
sw.WriteLine();
}
}
}
}
//页面引用
try
{
}
catch (Exception ex)
{
throw new Common.ExceptionLog(ex);
}

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

Dreamweaver CS6
视觉化网页开发工具

Atom编辑器mac版下载
最流行的的开源编辑器

禅工作室 13.0.1
功能强大的PHP集成开发环境

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中