2010-12-01 14 views
0

私はすべてのaspxリクエストをインターセプトしようとしています。インターセプトは機能しますが、ページは空白のままです。私は何が欠けていますか?インターセプト* .aspx

namespace WebSite 
{ 
    public class Class1 : IHttpHandler 
    { 
     public bool IsReusable 
     { 
      get { return true; } 
     } 

     public void ProcessRequest(HttpContext context) 
     { 

     } 
    } 
} 

<system.webServer> 
    <handlers> 
     <add name="SampleHandler" verb="*" 
     path="*.aspx" 
     type="WebSite.Class1, WebSite" 
     resourceType="Unspecified" /> 
    </handlers> 
    </system.webServer> 
+3

あなたはあなたの他の質問でいくつかの受け入れ答えを逃しています。 –

答えて

2

あなたはページリクエストを傍受していて、何もしていません。何らかの出力があると予想される場合は、渡されているHttpContextに対して何らかの操作を実行する必要があります。以下に、HttpContextを扱う際に読みやすいかもしれない2つの記事を示します。簡単に言えば、応答を見たい場合は、何かを生成する必要があります。

http://odetocode.com/Articles/112.aspx
What is the difference between HttpContext.Current.Response and Page.Response?
http://www.c-sharpcorner.com/uploadfile/desaijm/asp.netposturl11282005005516am/asp.netposturl.aspx

0

あなたは実際にそれらを傍受していません。それはそれらをハイジャックするようなものです。すべての* .aspx要求は実際の* .aspxページではなく、このハンドラに送られます。より適切な方法はApplication_BeginRequestハンドラをglobal.asaxに表示することです。

0

IhttpHandlerインターフェイスを使用して画像を処理しました。

IHttpHandlerFactoryは、私がページの傍受を処理するために使用するものである:

public class HttpCMSHandlerFactory : IHttpHandlerFactory 
{ 
    // collects page name requested 
    string pageName = Path.GetFileNameWithoutExtension(context.Request.PhysicalPath); 
    // Add the page name to the context 
    context.Items.Add("PageName", pageName); 
    // I can still check if the page physically exists else pass on to my CMS handler: CMSPage.aspx 
    FileInfo fi = new FileInfo(context.Request.MapPath(context.Request.CurrentExecutionFilePath)); 
    if (fi.Exists == false) 
    { 
     // if page doesnt exist context info is passed on to CMSPage to handle copy 
     return PageParser.GetCompiledPageInstance(string.Concat(context.Request.ApplicationPath, "/CMSPage.aspx"), url, context); 
    } 
    else 
    { 
     // if page exist physical page is returned 
     return PageParser.GetCompiledPageInstance(context.Request.CurrentExecutionFilePath, fi.FullName, context); 
    } 
} 

check out my previous post on the subject

関連する問題