I am trying to restrict direct access and downloading of files from my resources folder. I have implemented this in my global.asax:
It works however, it restricts my pages from using the resources as well... Can I somehow check if the request is being done from one of my pages?
Code:
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");
}
}
Comment