Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

asp.net È¥µôviewstate

½â¾ö°ì·¨£ºapp_code/ ´æ·ÅÒ»¸öÀà ÓÃÀ´½Ø»ñHTTP
1.´úÂëÈçÏÂ
using System;
using System.IO;
using System.Web;
using System.Text;
using System.Text.RegularExpressions;
/// <summary>
/// Removes whitespace from the webpage.
/// </summary>
public class ViewstateModule : IHttpModule
{
#region IHttpModule Members
void IHttpModule.Dispose()
{
// Nothing to dispose;
}
void IHttpModule.Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
#endregion
void context_BeginRequest(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
//if (app.Request.Url.OriginalString.Contains(".aspx"))
//{
// app.Response.Filter = new ViewstateFilter(app.Response.Filter);
//}
//reg/Ŀ¼ÏµIJ»½øÐÐÓÅ»¯ ÒòΪ·¢ÏÖrender ºó£¬ÑéÖ¤Âë²»ÄÜÏÔʾ
if (!app.Request.Url.OriginalString.Contains("/reg/"))
{
if (app.Request.Url.OriginalString.Contains(".aspx"))
{
app.Response.Filter = new ViewstateFilter(app.Response.Filter);
}
}
//¾²Ì¬»¯ºóÖØÒ²Òª´¦Àí
if (app.Request.Url.OriginalString.Contains(".html"))
{
app.Response.Filter = new ViewstateFilter(app.Response.Filter);
}
}
#region Stream filter
private class ViewstateFilter : Stream
{
public ViewstateFilter(Stream sink)
{
_sink = sink;
}
private Stream _sink;
#region Properites
public override bool CanRead
{
get { return true; }
}
public override bool CanSeek
{
get { return true; }
}
public override bool CanWrite
{
get { return true; }
}
public override void Flush()
{
_sink.Flush();
}


Ïà¹ØÎĵµ£º

ASP.NET Ê×Ò³ÐÔÄܵÄÊ®´ó×ö·¨

ASP.NET Ê×Ò³ÐÔÄܵÄÊ®´ó×ö·¨
Ç°ÑÔ
±¾ÎÄÊÇÎÒ¶ÔASP.NETÒ³ÃæÔØÈëËÙ¶ÈÌá¸ßµÄһЩ×ö·¨£¬ÕâЩ×ö·¨·ÖΪÒÔϲ¿·Ö£º
1.²ÉÓà HTTP Module ¿ØÖÆÒ³ÃæµÄÉúÃüÖÜÆÚ¡£
2.×Ô¶¨ÒåResponse.FilterµÃµ½Êä³öÁ÷streamÉú³É¶¯Ì¬Ò³ÃæµÄ¾²Ì¬ÄÚÈÝ(´ÅÅÌ»º´æ)¡£
3.Ò³ÃæGZIPѹËõ¡£
4.OutputCache ±à³Ì·½Ê½Êä³öÒ³Ã滺´æ¡£
5.ɾ³ýÒ³Ãæ¿Õ°××Ö·û´® ......

asp.netƽ̨ÉÏÁ¬½ÓÊý¾Ý¿â

 ½ñÌì¾À½áÁËÒ»ÉÏÎçµÄÎÊÌ⣬ÓÚÏÂÎç3µã12·Ö³¾°£Â䶨£¡
ÊÂÇéÊÇÕâÑùµÄ£º
×÷Ϊһ¸öÀï³Ì±®¼Ç¼Ï°ɣ¬Ò²ËãÊÇÎÒµÚÒ»´Î½«asp.netÓëÊý¾Ý¿â½áºÏ£¬²¢Íê³É´ÓÈí¼þ±à³Ìµ½webµÄ¹ý¶É¡£
Ôڴ˸Ðл½ñÌìΪÎÒ½â¾öÎÊÌâµÄ“ɱÊÖ”£¨Ò²³ÆÀϵÀ£©£¬»¹ÓÐÒÔǰΪÎÒ½â¾öÎÊÌâµÄ´ó¶Ó¡¢Óù·ç¡¢»ª¸çµÈÅ£...
ÑÔ¹éÕý´«£¬±¾ÎĽéÉÜÒ»ÏÂÔõÑùÔÚasp. ......

ÔÚASP.NETÖÐʹÓÃGlobal.asaxÎļþ


    Global.asaxÎļþ£¬ÓÐʱºò½Ð×öÓ¦ÓóÌÐòÎļþ£¬ÌṩÁËÒ»ÖÖÔÚÒ»¸öÖÐÐÄλÖÃÏìÓ¦Ó¦ÓóÌÐò¼¶»òÄ£¿é¼¶Ê¼þµÄ·½·¨¡£Äã¿ÉÒÔʹÓÃÕâ¸öÎļþʵÏÖÓ¦ÓóÌÐò°²È«ÐÔÒÔ¼°ÆäËüһЩÈÎÎñ¡£ÏÂÃæÈÃÎÒÃÇÏêϸ¿´Ò»ÏÂÈçºÎÔÚÓ¦Óù¤×÷ÖÐʹÓÃÕâ¸öÎļþ¡£
¸ÅÊö
Global.asaxλÓÚÓ¦ÓóÌÐò¸ùĿ¼Ï¡£ËäÈ»VisualStudio.NET»á×Ô¶¯²åÈëÕâ¸öÎ ......

ASP.NET ÅжÏÍøÒ³±àÂë¶ÁÈ¡ÄÚÈÝ£¬·ÀÖ¹ÂÒÂë

×î½üҪдһ¸öÔÚÍøÒ³ÖвéÕҹؼü×Ö¼°Á´½ÓµÄ³ÌÐò£¬ÔÚÊä³öµ½TextBoxµÄʱºò·¢ÏÖ¾­³£³öÏÖÂÒÂ룬ÕûÀíÁËһϸù¾Ý²»Í¬µÄ±àÂëÑ¡È¡ÍøÒ³Ô´Îļþ£¬Ä¿Ç°¿ÉÒÔ½â¾ö¼¸ÖÖ³£±àÂ뷽ʽµÄÍøÒ³£¬¸ÐÐËȤµÄ¿ÉÒÔÊÔÏ¡£
±¾À´ÏëÓÓ£½£½”ÅжϱàÂ룬¸Ð¾õ±È½ÏÂé·³£¬ËùÒÔ¸ÄÓñȽÏÄ£ºýµÄ·½·¨£¬ContainsÓÃÔÚÕâÀïͦ·½±ãµÄ¡£
Contains˵Ã÷£º¾ÍÊÇ·µ» ......

ASP.NET ÈçºÎʵÏÖα¾²Ì¬

ÆäʵËùνµÄα¾²Ì¬Ò³Ãæ,¾ÍÊÇÖ¸µÄURLÖØд.
1.Ê×ÏÈÔÚweb.configÀïд
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>

2.ÔÚweb.configÀïÌí¼ÓÒÔϽڵã
<httpHandlers>
< ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ