检查请求是由用户还是按页面

时间:2013-08-15 12:51:47

标签: asp.net request global-asax hotlinking

我正在尝试限制从我的资源文件夹直接访问和下载文件。我在global.asax中实现了这个:

void Application_BeginRequest(object sender, EventArgs e)
{
    HttpApplication application = (HttpApplication)sender;
    HttpRequest request = application.Context.Request;

    if (request.Url.ToString().Contains(@"/resources/"))
    {
        Server.ClearError();
        Response.Clear();
        Response.Redirect(@"http://mysitename.com/download_restriction.aspx");
    }
}

但它有效,它限制我的页面也不使用资源......我可以以某种方式检查请求是否是从我的一个页面完成的吗?

1 个答案:

答案 0 :(得分:0)

使用会话变量来了解您来自您的应用

相关问题