2013-10-12 86 views
0

客户使用http://aaa.com/uploads/bb/index.html来请求我的ASP.NET MVC网站。我想确保客户有足够的权限访问该网站,所以我需要赶上请求并处理它。我正在使用IHttpModule来做到这一点。通过asp.net mvc网站的html请求

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

    void context_BeginRequest(object sender, EventArgs e) 
    { 
     HttpApplication application = (HttpApplication)sender; 

     Uri url = application.Context.Request.Url; 
     string path = url.AbsoluteUri; 
    } 
} 

的问题是,当第二次使用相同的URL请求的网站,该HttpModule不能赶上请求。

回答

0

得到了答案!它是关于http缓存。 我写如下代码和问题被杀:

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

void context_BeginRequest(object sender, EventArgs e) 
{ 
    HttpApplication application = (HttpApplication)sender; 

    Uri url = application.Context.Request.Url; 
    string path = url.AbsoluteUri; 
    **app.Response.Cache.SetCacheability(HttpCacheability.NoCache);** 
} 

}