Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Restrict users to access the help file, download js files

Restrict users to access the help file, download js files

Scheduled Pinned Locked Moved ASP.NET
questionjavajavascripthtmlsecurity
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rijz
    wrote on last edited by
    #1

    Hi all, I have a set of help files(html files) in the application root directory. Now these HTML files can be accessed by the users even if they are not logged into the application. How can I restrict this? Similarly, how can I restrict users to download java script files which is in my application root directory by directly typing the URL in the browser. Please note, the authentication mode is windows and framework used is 1.1. Kindly help... Thanks in advance.. Rijz

    A 1 Reply Last reply
    0
    • R Rijz

      Hi all, I have a set of help files(html files) in the application root directory. Now these HTML files can be accessed by the users even if they are not logged into the application. How can I restrict this? Similarly, how can I restrict users to download java script files which is in my application root directory by directly typing the URL in the browser. Please note, the authentication mode is windows and framework used is 1.1. Kindly help... Thanks in advance.. Rijz

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Well.. .Actually browser makes separate http request for each individual external files.

      Rijz wrote:

      Now these HTML files can be accessed by the users even if they are not logged into the application. How can I restrict this?

      To make access to the html files.. I would suggest to use separate HttpHandler which will authenticate your request againist some session id, if session is created already or will do it using uid and password.

      Rijz wrote:

      Similarly, how can I restrict users to download java script files which is in my application root directory by directly typing the URL in the browser.

      In case of Javascript as a separate request is made from the browser, it would not be a good idea to restrict the download of the file. Some browser requests javascript after document is fully loaded, but there are others which actually starts download of the file as soon as it parses the Javascript tag. So you cant trap the behaviour of the browser. Rather, I would suggest you to edit your javascript and place your sessionid within the url. Place your sessionid in a sesssion variable or in database. Create a separate HttpHandler for Js file which will check if the sessionid(might be your custom GUID which you generate during the login) passed with the querystring is valid for the current user. Allow download of the javascript only when url is valid. say in your browser you place script tag like this <script type="text/javascript" src="yourjavascript.js?sessionId=<%=this.Session.SessionId%> Now from ProcessRequest of IHttpHandler, check

      string qry = context.Request.QueryString["sessionId"] as string;
      if(!context.Session.SessionId.equals(qry))
      {
      context.Response.clear();
      context.Response.close();
      }

      Also remember to implement your class from RequiresSessionState, otherwise session will not be available in the

      HttpHandler

      . Hope you got the idea. :rose::rose:

      Abhishek Sur


      My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

      **Don'

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups