473,394 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Checking that ASP page hasn't been accessed directly.

Hi All

I've been looking at having my Javascript file as an ASP one to try and stop
general prying eyes, eg:

<SCRIPT LANGUAGE="javascript" SRC="js-something.asp">
</SCRIPT>

and this seems to work well apart from the fact that if the user, puts in
for example:

www.mydomain.co.uk/js-something.asp

the javascript is written to the web page for them to see.

Is it possible for the ASP side of this file to check whether it is has been
accessed directly (eg, as per the URL above) rather than simply being SRC'd
inside another ASP page?

If I can do a check for this then in my ASP code I could put that I only
write the javascript code if the page isn't being accessed directly.

Does this make sense?

Is the code still unprotected?

Thanks

Laphan
Jul 19 '05 #1
5 1877
Laphan wrote:

<SCRIPT LANGUAGE="javascript" SRC="js-something.asp">
</SCRIPT>

and this seems to work well apart from the fact that if the user,
puts in for example:

www.mydomain.co.uk/js-something.asp

the javascript is written to the web page for them to see.

Is it possible for the ASP side of this file to check whether it is
has been accessed directly (eg, as per the URL above) rather than
simply being SRC'd inside another ASP page?


How important is this, really?

Client-side code *must* be visible to the user agent, so there is no real
way of keeping me from viewing it. But I can think of a way to make it
difficult...

First of all, you have already made the JS file an ASP script. Good. Now tie
it to a one-time-use "random" value on the server:
Your ASP Script
================================================== =====================
Call Randomize()
Session("js-something") = Rnd()
<SCRIPT SRC="js-something.asp?r=<%=Session("js-something")%>"></SCRIPT>
js-something.asp
================================================== =====================
If Response.QueryString("r") <> Session("js-something") Then
Response.End()
End If
Session("js-something") = null
Add some expiration to the JS file, and this ought to help. Of course, it
assumes cookies are enabled. If you want to make it work for cookieless
requests, you'll need to put the random value into a DB.
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #2
You're trying to protect the JavaScript code? As http://www.aspfaq.com/2175
will demonstrate, the way to do this is to print it out and put it in your
safety deposit box.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Laphan" <ne**@DoNotEmailMe.co.uk> wrote in message
news:40********@127.0.0.1...
Hi All

I've been looking at having my Javascript file as an ASP one to try and stop general prying eyes, eg:

<SCRIPT LANGUAGE="javascript" SRC="js-something.asp">
</SCRIPT>

and this seems to work well apart from the fact that if the user, puts in
for example:

www.mydomain.co.uk/js-something.asp

the javascript is written to the web page for them to see.

Is it possible for the ASP side of this file to check whether it is has been accessed directly (eg, as per the URL above) rather than simply being SRC'd inside another ASP page?

If I can do a check for this then in my ASP code I could put that I only
write the javascript code if the page isn't being accessed directly.

Does this make sense?

Is the code still unprotected?

Thanks

Laphan

Jul 19 '05 #3
On Fri, 25 Jun 2004 20:09:59 +0100, "Laphan" <ne**@DoNotEmailMe.co.uk> wrote:
Hi All

I've been looking at having my Javascript file as an ASP one to try and stop
general prying eyes, eg:

<SCRIPT LANGUAGE="javascript" SRC="js-something.asp">
</SCRIPT>

and this seems to work well apart from the fact that if the user, puts in
for example:

www.mydomain.co.uk/js-something.asp

the javascript is written to the web page for them to see.

Is it possible for the ASP side of this file to check whether it is has been
accessed directly (eg, as per the URL above) rather than simply being SRC'd
inside another ASP page?

If I can do a check for this then in my ASP code I could put that I only
write the javascript code if the page isn't being accessed directly.

Does this make sense?

Is the code still unprotected?

Thanks

Laphan

Make the aps code part of an HTML page and , right after the <BODY> tag, add
<SCRIPT Language="JavaScript">
if (document.referrer != "http://Thepageyouwantitobefrom") {
location.href="http://somemessagepage.asp"
}
</SCRIPT>

Probably not an absolute, but it works in our setting..
Jul 19 '05 #4
Turkbear wrote:
Make the aps code part of an HTML page and , right after the <BODY>
tag, add <SCRIPT Language="JavaScript">
if (document.referrer != "http://Thepageyouwantitobefrom") {
location.href="http://somemessagepage.asp"
}
</SCRIPT>

Probably not an absolute, but it works in our setting..


Only because your users don't know to look at their cache. Anyone who wants
to see the code will be able to .

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #5
> Probably not an absolute, but it works in our setting..

Yep, Bob is right. Show me where this technique "protects" your JavaScript
code, and I'll show you your "protected" JavaScript code.

A
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Henry Hartley | last post by:
I've got a PHP system working on a development server (Windows 2000/IIS5/PHP 4.3.3) but it doesn't seem to be working quite right on the testing server (same except PHP 4.2.3). I upgraded the PHP...
1
by: ben h | last post by:
can I include into an .asp page a script file? My script file would have a bunch of functions written in VBScript, say, and my asp page also in VBScript. I want to be able to write a few...
2
by: dereking | last post by:
Hi all, How can I write an asp page, say, CHECKIP.asp that checks the incomin requesting IP address and returns a protected page, based on th checking result? That is, if the IP is a permitted...
3
by: DotNetJunkies User | last post by:
I am getting the "This type of page is not served." error the first time I access our asp.net site after an application restart. The second and every other time it works fine. This application has...
8
by: Ed Jay | last post by:
I want to use history.go() to navigate between my previously loaded pages. I'm looking for a way to trigger a function call when a page is accessed using history.go(). Is there an event generated?...
1
by: Jerim79 | last post by:
I have a 3 page PHP script. I only want people to be able to access the first page of the script by URL. The other 2 pages need to return a message such as "This page can not be accessed directly."...
1
by: Nithu25 | last post by:
HI All, In my project, i am including a third party script in one page which displays a calendar. When this page is accessed directly by giving the URL in the address bar, the calendar appears....
8
by: aarklon | last post by:
Hi all, see:- http://linuxgazette.net/issue51/pramode.html
7
by: seanmatthewwalsh | last post by:
Hi I have a page (default.aspx) that pulls it's HTML from a database. I then have a "content management" page (editpage.aspx) that allows the user to edit the HTML in the database. When the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.