Deny downloading of resources by checking if the request is from a page component or

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nexvotum
    New Member
    • Aug 2013
    • 1

    #1

    Deny downloading of resources by checking if the request is from a page component or

    I am trying to restrict direct access and downloading of files from my resources folder. I have implemented this in my global.asax:
    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");
        }
    }
    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?
    Last edited by Frinavale; Aug 20 '13, 02:59 PM. Reason: Added code tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Have you considered using proper Authentication and Authorization like forms authentication?

    -Frinny

    Comment

    • univercel
      New Member
      • Aug 2013
      • 11

      #3
      You may check referral URL for this HTTP request.

      Comment

      Working...