Click here to Skip to main content
15,917,538 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Restrict users to access the help file, download js files Pin
Abhishek Sur16-Sep-09 9:21
professionalAbhishek Sur16-Sep-09 9:21 
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] Rose | [Rose]

Abhishek Sur

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

Don't forget to click "Good Answer" if you like to.

QuestionAjax AutoComplete Extender(urgent) Pin
Devkranth Kishore Vanja16-Sep-09 1:57
Devkranth Kishore Vanja16-Sep-09 1:57 
AnswerRe: Ajax AutoComplete Extender(urgent) Pin
Arun Jacob16-Sep-09 1:59
Arun Jacob16-Sep-09 1:59 
GeneralRe: Ajax AutoComplete Extender(urgent) Pin
J4amieC16-Sep-09 2:19
J4amieC16-Sep-09 2:19 
AnswerRe: Ajax AutoComplete Extender(urgent) Pin
Arun Jacob16-Sep-09 2:31
Arun Jacob16-Sep-09 2:31 
GeneralRe: Ajax AutoComplete Extender(urgent) Pin
J4amieC16-Sep-09 2:35
J4amieC16-Sep-09 2:35 
GeneralRe: Ajax AutoComplete Extender(urgent) Pin
Arun Jacob16-Sep-09 2:41
Arun Jacob16-Sep-09 2:41 
AnswerRe: Ajax AutoComplete Extender(urgent) Pin
J4amieC16-Sep-09 2:37
J4amieC16-Sep-09 2:37 
QuestionDynamic Item tmpate inside gridview Pin
sekannak16-Sep-09 1:28
sekannak16-Sep-09 1:28 
AnswerRe: Dynamic Item tmpate inside gridview Pin
Christian Graus16-Sep-09 1:37
protectorChristian Graus16-Sep-09 1:37 
AnswerRe: Dynamic Item tmpate inside gridview Pin
Arun Jacob16-Sep-09 1:54
Arun Jacob16-Sep-09 1:54 
Questionajax controls not working fine..,when evets not fire for some time..., Pin
Member 387988116-Sep-09 0:52
Member 387988116-Sep-09 0:52 
AnswerRe: ajax controls not working fine..,when evets not fire for some time..., Pin
Christian Graus16-Sep-09 1:36
protectorChristian Graus16-Sep-09 1:36 
AnswerRe: ajax controls not working fine..,when evets not fire for some time..., Pin
Shalini_U16-Sep-09 3:11
Shalini_U16-Sep-09 3:11 
QuestionDatabinding Pin
Member 448708316-Sep-09 0:23
Member 448708316-Sep-09 0:23 
AnswerRe: Databinding Pin
Christian Graus16-Sep-09 1:35
protectorChristian Graus16-Sep-09 1:35 
AnswerRe: Databinding Pin
Muhammad Mazhar17-Sep-09 9:35
Muhammad Mazhar17-Sep-09 9:35 
QuestionAccess Denied in CreateDirectory with UNC Path Pin
Stephan Pilz15-Sep-09 23:49
Stephan Pilz15-Sep-09 23:49 
AnswerRe: Access Denied in CreateDirectory with UNC Path Pin
Christian Graus16-Sep-09 1:33
protectorChristian Graus16-Sep-09 1:33 
GeneralRe: Access Denied in CreateDirectory with UNC Path Pin
Stephan Pilz16-Sep-09 2:47
Stephan Pilz16-Sep-09 2:47 
Questionproblem in text box Pin
na3em 200915-Sep-09 23:48
na3em 200915-Sep-09 23:48 
AnswerRe: problem in text box Pin
Christian Graus16-Sep-09 1:32
protectorChristian Graus16-Sep-09 1:32 
Questionproblem due to use of modalpopupExtender Pin
saiftanoli15-Sep-09 22:12
saiftanoli15-Sep-09 22:12 
AnswerRe: problem due to use of modalpopupExtender Pin
Muhammad Mazhar17-Sep-09 9:37
Muhammad Mazhar17-Sep-09 9:37 
QuestionIp Address Pin
Ramkumar_S15-Sep-09 21:29
Ramkumar_S15-Sep-09 21:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.