問題描述
將 HttpModule 添加到 web.config 時未加載 ASP.NET CSS 文件 (ASP.NET CSS file not loaded when adding HttpModule to web.config)
我正在使用 c# 和 ASP.NET 3.5 製作網站,我剛剛製作了一個 HttpModule 來處理 NHibernate 會話生命(打開和關閉)。我將它添加到 web.config 並且一切正常。(所有查詢、代碼等工作正常)除了我的母版頁的 CSS 文件沒有加載!!
這對我來說太奇怪了,你知道這種行為的原因是什麼嗎?< /p>
謝謝大家,
參考解法
方法 1:
at last i found the solution, the problem source is working with the session in the HttpModule events cause strange problems.
It looks like it is a known issue and whether or not session state is available is actually decided... by the SessionStateModule itself! Briefly, in order to force session state to load current Context.Handler, usually DefaultHttpHandler, has to be replaced in the PostMapRequestHandler event by some other handler, implementing IRequiresSessionState. To be safe, my dummy handler carries a reference to the original handler, and I swap it back in the PostAcquireRequestState event, once the dummy handler fulfilled its purpose.
actually it is a known issue in Asp.net and IIS and the solution is reported Here at ASP.NET forum. also there is a sample code to solve the problem in link. I tested and my problem solved!
Thanks All,