Protect Your Code

Submitted on: 1/6/2015 1:38:00 AM
By: dselkirk (from psc cd)  
Level: Intermediate
User Rating: By 3 Users
Compatibility: ASP (Active Server Pages)
Views: 3840
     Simple way of preventing access to your client side javascripts and even style sheets

				I know that very single web developer has either wanted or has been asked
if they can protect there client side scripts. Now there's an answer, it
quite simply prevents an individual from downloading a HTML pages external
scripts files. 

How it works
Every good developer knows to rename all there script files to the asp extension to protect their asp code. This unforunitely does not protect your client side scripts. The way around it is since we already have our files renamed to asp extensions, why not take advantage of it. All we need to do is implement the response.end statement before the actualy script and nothing will be viewed. The tricky part is to detect whether or not you to allow the page to render. We can do this by performing some simple request.servervariable checks. I create an include file called "validate_view.asp". I simply include the file at the top of each script file. I then call the procedure "validate_view" which is contained in the include file. This will perform the check. I also pass the content type with the procedure to make the page react as it should normally. The procedure then performs some basic checks of where you came from, what domain is being used and a couple others. You can even pass a querystring called page_pass which allows you to view the page from anywhere. You can even customize various parts of the code for your own personal needs.

Download example

I appreciate any comments or suggestions you may have.

Other 5 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.