中文字幕精品亚洲无线码二区,国产黄a三级三级三级看三级,亚洲七七久久桃花影院,丰满少妇被猛烈进入,国产小视频在线观看网站

基礎才是重中之重~網站bin目錄下的程序(xu)集自(zi)動(dong)加載

回到目錄

網站bin目(mu)(mu)(mu)錄(lu)下的(de)程序集一般由系(xi)統項(xiang)(xiang)目(mu)(mu)(mu),項(xiang)(xiang)目(mu)(mu)(mu)引用(yong)的(de)外(wai)(wai)部DLL及(ji)外(wai)(wai)掛DLL組成,它(ta)們在(zai)網站運行(xing)時(shi)會自動(dong)加(jia)載,這一點很重要,項(xiang)(xiang)目(mu)(mu)(mu)本(ben)身(shen)DLL及(ji)項(xiang)(xiang)目(mu)(mu)(mu)引入(ru)的(de)DLL會自動(dong)加(jia)載,這沒有問題,而外(wai)(wai)掛在(zai)bin目(mu)(mu)(mu)錄(lu)的(de)DLL也(ye)會自動(dong)加(jia)載,這很重要,因為,它(ta)可以使(shi)我們的(de)應用(yong)程序更(geng)(geng)加(jia)靈活,在(zai)開發通(tong)用(yong)功能上,也(ye)顯得擴展(zhan)性更(geng)(geng)強!

一個(ge)例子(zi),比如一個(ge)HttpModule,它(ta)是一個(ge)通用(yong)的(de)功能(neng),向頁(ye)面添(tian)加一些緩存過期的(de)共用(yong)信息,這對于(yu)你所有網站都(dou)是共用(yong)的(de),這時,可以建(jian)立一個(ge)HttpModule項目,它(ta)代(dai)碼(ma)可能(neng)是這樣

namespace TestHttpModule
{
    public class SEOModule : IHttpModule
    {
        #region IHttpModule 成員

        public void Dispose()
        {
            throw new NotImplementedException();
        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }

        void context_BeginRequest(object sender, EventArgs e)
        {
            var application = (HttpApplication)sender;
            application.Context.Response.Expires = 0;
            application.Context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
            application.Context.Response.AddHeader("pragma", "no-cache");
            application.Context.Response.AddHeader("cache-control", "private");
        }
        #endregion
    }
}

而(er)對于目錄網站來(lai)說,只(zhi)需要在web.config中配置一(yi)下這個(ge)module就(jiu)可以(yi)了

  </pages>
    <httpModules>
      <add name="SEOModule" type="TestHttpModule.SEOModule"/>
    </httpModules>
  </system.web>

而將(jiang)這個(ge)module.dll直接復制到目(mu)標網(wang)站的bin目(mu)錄下,網(wang)站運行(xing)就即可自動加(jia)載了。

事(shi)實上,我們通過.net應用(yong)程序的(de)這個項目(mu)(mu),可以開發很(hen)多通用(yong)的(de)模塊(kuai),并很(hen)好的(de)與具體(ti)項目(mu)(mu)結(jie)合,實現具體(ti)項目(mu)(mu)的(de)“功能性熱插拔”!

回到目錄

posted @ 2013-04-02 10:10  張占嶺  閱讀(1557)  評論(0)    收藏  舉報