asp.net×Ô¶¨Òå´íÎóÒ³Ãæ
web.config
<customErrors mode="On" defaultRedirect="ApplicationErroy.aspx" >
<error statusCode="403" redirect="403.htm"/>
<error statusCode="404" redirect="404.htm"/>
<error statusCode="500" redirect="500.htm"/>
</customErrors>
Global.asax
<%@ Application Language="C#" %>
<mce:script runat="server"><!--
void Application_Start(object sender, EventArgs e)
{
// ÔÚÓ¦ÓóÌÐòÆô¶¯Ê±ÔËÐеĴúÂë
}
void Application_End(object sender, EventArgs e)
{
// ÔÚÓ¦ÓóÌÐò¹Ø±ÕʱÔËÐеĴúÂë
}
void Application_Error(object sender, EventArgs e)
{
// ÔÚ³öÏÖδ´¦ÀíµÄ´íÎóʱÔËÐеĴúÂë
Exception erroy = Server.GetLastError();
string err = "³ö´íÒ³ÃæÊÇ£º" + Request.Url.ToString() + "</br>";
err += "Òì³£ÐÅÏ¢£º" + erroy.Message + "</br>";
err += "Source:" + erroy.Source + "</br>";
err += "StackTrace:" + erroy.StackTrace + "</br>";
//Çå³ýǰһ¸öÒì³£
Server.ClearError();
//´Ë´¦ÀíÓÃSession["ProError"]³ö´í¡£ËùÒÔÓà Application["ProError"]
Application["erroy"] = err;
//´Ë´¦²»ÊÇpageÖУ¬²»ÄÜÓÃResponse.Redirect("../frmSysError.aspx");
System.Web.HttpContext.Current.Response.Redirect(HttpContext.Current.Request.ApplicationPath + "/ApplicationErroy.aspx");
}
void Session_Start(object sender, EventArgs e)
{
// ÔÚлỰÆô¶¯Ê±ÔËÐеĴúÂë
}
void Session_End(object sender, EventArgs e)
{
// ÔڻỰ½áÊøÊ±ÔËÐеĴúÂë¡£
// ×¢Òâ: Ö»ÓÐÔÚ Web.config ÎļþÖÐµÄ sessionstate ģʽÉèÖÃΪ
// InProc ʱ£¬²Å»áÒý·¢ Session_End ʼþ¡£Èç¹û»á»°Ä£Ê½É
Ïà¹ØÎĵµ£º
.net À¬»ø»ØÊÕ»úÖÆ ¡¾×ªÌû¡¿
2009-02-13 17:44
netÄÚ´æ»ØÊÕÓëDispose﹐Close﹐Finalize·½·¨
Ò». netµÄ¶ÔÏóʹÓÃÒ»°ã·ÖΪÈýÖÖÇé¿ö﹕
1.´´½¨¶ÔÏó
2.ʹÓöÔÏó
3.ÊͷŶÔÏó
¶þ.´´½¨¶ÔÏó
1.´´½¨¶ÔÏóʵ¼Ê·ÖΪÁ½¸ö²½Öè﹕±äÁ¿ÀàÐÍÐû¸æºÍ³õʼ»¯¶ÔÏó
2.±äÁ¿ÀàÐÍÐû¸æ(declare),Èç﹕
FileStream ......
ÔÚÓÃVS2008µ÷ÊÔÍøÕ¾µÄʱºò£¬Í»È»Ò³Ãæ²»ÄÜÕý³£ÏÔʾÁË£¬IEÏÔʾ“ÎÞ·¨ÏÔʾ¸ÃÍøÒ³”¡£
Ö¢×´Ò»£º
¡¡¡¡IEµØÖ·À¸ÀïÃæÏÔʾµÄ¶Ë¿ÚºÅºÍ×ÀÃæÈÎÎñÀ¸ÓÒϽǓASP.NET Development Server”µÄ¶Ë¿Ú²»Ò»Ö£¬¶ø°ÑIEµØÖ·À¸µÄ¶Ë¿ÚºÅ¸Ä³É“ASP.NET Development Server”ÏÔʾµÄ¶Ë¿ÚºÅ£¬½á¹ûÍøÒ³¾ÍÄܳöÀ´¡£
½â¾ö ......
µ±Ð´´½¨Ò»¸öasp.net mvcÓ¦ÓóÌÐò£¬»á×Ô¶¯²úÉúÒ»¸ö·ÓÉÅäÖá£
Global.asax.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace mvcApp
{
// Note: For instructions on enabling IIS6 or IIS7 classic m ......
¶ÏµãÐø´«µÄÔÀí
ÔÚÁ˽âHTTP¶ÏµãÐø´«µÄÔÀí֮ǰ£¬ÏÈÀ´ËµËµHTTPÐÒ飬HTTPÐÒéÊÇÒ»ÖÖ»ùÓÚtcpµÄ¼òµ¥ÐÒ飬·ÖΪÇëÇóºÍ»Ø¸´Á½ÖÖ¡£ÇëÇóÐÒéÊÇÓɿͻ§»ú(ä¯ÀÀÆ÷)Ïò·þÎñÆ÷(WEB SERVER)Ìá½»ÇëÇóʱ·¢Ëͱ¨ÎĵÄÐÒé¡£»Ø¸´ÐÒéÊÇÓÉ·þÎñÆ÷(web server)£¬Ïò¿Í»§»ú(ä¯ÀÀÆ÷)»Ø¸´±¨ÎÄʱµÄÐÒé¡£ÇëÇóºÍ»Ø¸´ÐÒé¶¼ÓÉÍ·ºÍÌå×é³É¡£Í·ºÍÌåÖ® ......
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Text;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Sy ......