ASP.NET Ê×Ò³ÐÔÄܵÄÊ®´ó×ö·¨
ASP.NET Ê×Ò³ÐÔÄܵÄÊ®´ó×ö·¨
Ç°ÑÔ
±¾ÎÄÊÇÎÒ¶ÔASP.NETÒ³ÃæÔØÈëËÙ¶ÈÌá¸ßµÄһЩ×ö·¨£¬ÕâЩ×ö·¨·ÖΪÒÔϲ¿·Ö£º
1.²ÉÓà HTTP Module ¿ØÖÆÒ³ÃæµÄÉúÃüÖÜÆÚ¡£
2.×Ô¶¨ÒåResponse.FilterµÃµ½Êä³öÁ÷streamÉú³É¶¯Ì¬Ò³ÃæµÄ¾²Ì¬ÄÚÈÝ(´ÅÅÌ»º´æ)¡£
3.Ò³ÃæGZIPѹËõ¡£
4.OutputCache ±à³Ì·½Ê½Êä³öÒ³Ã滺´æ¡£
5.ɾ³ýÒ³Ãæ¿Õ°××Ö·û´®¡££¨ÀàËÆGoogle£©
6.Íêȫɾ³ýViewState¡£
7.ɾ³ý·þÎñÆ÷¿Ø¼þÉú³ÉµÄÀ¬»øNamingContainer¡£
8.ʹÓüƻ®ÈÎÎñ°´Ê±Éú³ÉÒ³Ãæ¡££¨±¾ÎIJ»°üº¬¸Ã×ö·¨µÄʵÏÖ£©
9.JS£¬CSSѹËõ¡¢ºÏ²¢¡¢»º´æ£¬Í¼Æ¬»º´æ¡££¨ÏÞÓÚÎÄÕÂƪ·ù£¬±¾ÎIJ»°üº¬¸Ã×ö·¨µÄʵÏÖ£©
10.»º´æÆÆ»µ¡££¨²»°üº¬µÚ9×ö·¨µÄʵÏÖ£©
Õë¶ÔÉÏÊö×ö·¨£¬ÎÒÃÇÊ×ÏÈÐèÒªÒ»¸ö HTTP Ä£¿é£¬ËüÊÇÕû¸öÒ³ÃæÁ÷³ÌµÄÈë¿ÚºÍºËÐÄ¡£
Ò»¡¢×Ô¶¨ÒåResponse.FilterµÃµ½Êä³öÁ÷streamÉú³É¶¯Ì¬Ò³ÃæµÄ¾²Ì¬ÄÚÈÝ(´ÅÅÌ»º´æ)
ÈçϵĴúÂëÎÒÃÇ¿ÉÒÔ¿´³ö£¬ÎÒÃÇÒÔ request.RawUrl Ϊ»º´æ»ù´¡£¬ÒòΪËü¿ÉÒÔ°üº¬ÈÎÒâµÄQueryString±äÁ¿£¬È»ºóÎÒÃÇÓÃMD5¼ÓÃÜRawUrl µÃµ½·þÎñÆ÷±¾µØÎļþÃûµÄ±äÁ¿£¬ÔÙʵÀý»¯Ò»¸öFileInfo²Ù×÷¸ÃÎļþ£¬Èç¹ûÎļþ×îºóÒ»´ÎÉú³Éʱ¼äСÓÚ7Ì죬ÎÒÃǾÍʹÓÃ.Net2.0ÐÂÔöµÄTransmitFile·½·¨½«´æ´¢ÎļþµÄ¾²Ì¬ÄÚÈÝ·¢Ë͵½ä¯ÀÀÆ÷¡£Èç¹ûÎļþ²»´æÔÚ£¬ÎÒÃǾͲÙ×÷ response.Filter µÃµ½µÄ Stream ´«µÝ¸ø CommonFilter À࣬²¢ÀûÓÃFileStreamдÈ붯̬ҳÃæµÄÄÚÈݵ½¾²Ì¬ÎļþÖС£
namespace ASPNET_CL.Code.HttpModules {
public class CommonModule : IHttpModule {
public void Init( HttpApplication application ) {
application.BeginRequest += Application_BeginRequest;
}
private void Application_BeginRequest( object sender, EventArgs e ) {
var context = HttpContext.Current;
var request = context.Request;
var url = request.RawUrl;
var response = context.Response;
var path = GetPath( url );
var file = new FileInfo( path );
if ( DateTime.Now.Subtract( file.LastWriteTime ).TotalDays < 7 ) {
response.TransmitFile( path );
response.End();
return;
}
try {
var stream = file.OpenWrite();
Ïà¹ØÎĵµ£º
¿´µ½ÓÐÈËÌáÎÊÒ»¸ö¿Õ¼äÖ§³Ö¶à¸öÍøÕ¾µÄÎÊÌâ¡£
×ܽáһϣº
×îºÃ±£Ö¤¸÷¸öÏîÄ¿app_codeÄÚµÄÎļþ¶¼ÊÇÒ»ÑùµÄ¡£
ÒòΪÉú³É¶à¸öÏîÄ¿±Ø¶¨Éú³É¶à¸öApp_Code.dll£¬
ÓÉÓÚËùÓÐdll·ÅÔÚͬһ¸öbinĿ¼£¬ËùÒÔÒª±£Ö¤app_codeÄÚµÄÎļþÒ»Ñù¡£
·¢²¼Ç°ËùÓÐÏîÄ¿aspxÎļþµÄ Inherits="menulefttb" ÖеÄÃû×Ö²»ÄÜÏàͬ¡£
½«Ã¿¸öÏîÄ¿·¢²¼ºóÉú³ÉµÄdll ......
Web Ò³ÃæÊÇÎÞ״̬µÄ£¬ ·þÎñÆ÷¶Ôÿһ´ÎÇëÇó¶¼ÈÏΪÀ´×Ô²»Í¬Óû§£¬Òò´Ë£¬±äÁ¿µÄ״̬ÔÚÁ¬Ðø¶ÔͬһҳÃæµÄ¶à´ÎÇëÇóÖ®¼ä»òÔÚÒ³ÃæÌøתʱ²»»á±»±£Áô¡£
0¡¢ÒýÑÔ
Web Ò³ÃæÊÇÎÞ״̬µÄ£¬·þÎñÆ÷¶Ôÿһ´ÎÇëÇó¶¼ÈÏΪÀ´×Ô²»Í¬Óû§£¬Òò´Ë£¬±äÁ¿µÄ״̬ÔÚÁ¬Ðø¶ÔͬһҳÃæµÄ¶à´ÎÇëÇóÖ®¼ä»òÔÚÒ³ÃæÌøתʱ²»»á±»±£Áô¡£ÔÚÓÃAsp.NET Éè¼Æ¿ª·¢Ò»¸öWeb ......
VS ASP.NETÉèÖöϵã ÎÞ·¨µ÷ÊÔ
ÎҵĿª·¢¹¤¾ßVS2005 IEä¯ÀÀÆ÷ÊÇ8.0£¬ÉèÖöϵãÖ®ºó²»Äܵ÷ÊÔ¡£
Ò»°ã»áÓÐÁ½ÖÖ¿ÉÄÜ£º
Ò»¡¢web.config debugÊôÐÔÉèÖÃΪTRUE
<compilation debug="true" />
¶þ¡¢IE8µÄÎÊÌâ
ÐÞ¸Ä×¢²á±í£ºHKEY_LOCALMACHINE -> SOFTWARE -> Microsoft -> Internet Explorer -> Main
ÐÂÔöÃû³ ......
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Text;
namespace Maticsoft.DBUtility
{
/// <summary>
  ......
ASP.NET ViewState ÊÇÒ»ÖÖеÄ״̬·þÎñ£¬¿É¹©¿ª·¢ÈËÔ±»ùÓÚÿ¸öÓû§À´¸ú×Ù UI ״̬£¬¸Ã¸¨ÖúÊý¾Ý±»´æ´¢ÔÚÒ»¸öÃûΪ __VIEWSTATE µÄÒþ²Ø×Ö¶ÎÖС£
µ±È»£¬ ViewState ÔÚ ASP.NET ÖÐÓиöÖØÒªµÄ½ÇÉ«¡£Èç¹ûʹÓÃÇ¡µ±£¬ËüÄܹ»¼ò»¯Ò³Ã濪·¢£¬¸Ä½øÓû§ÓëÕ¾µãµÄ½»»¥¡£Èç¹ûÖÃÖ®²»Àí£¬ËüÄܹ»ÏÔÖøÔö¼ÓÕ¾µãÏìÓ¦´óÐ ......