.Net Web Protection (Content Management)
Intro
This project aims to create practical web protections using html implementation logic and helps developers to manipulate their web pages on the fly before rendered. Protections that are represented in this library are highly useful while developing dynamic websites in both Asp.Net WebForms and MVC applications.
How to start?
In WebForms
- Add a reference to the files “ProtectionCore.dll” and “WebFormsProtection.dll”.
- Replace “PageName : System.Web.UI.Page” with “PageName : Core.Web.ProtectedPage” in class declaration line.
- Start using “Protection” field in the Page_Load event. You can try “Protection.DisableRightClick();” as an example.
In MVC
- Add a reference to the files “ProtectionCore.dll” and “MVCProtection.dll”.
- Add “using Core.Web;” statement to the top of the page.
- Add “[Protected]” attribute to Controller or Action you want.
- Start using “this.Protection()” extension in the Controller or Action. You can try “this.Protection().DisableDragDrop();” as an example.
Also in the Views you can add ”@using Core.Web” to page and use HtmlHelper extension. Example: ”@Html.Protection().SessionLink(“/Home/About”,randomLink: true, isPage: true)”, this will create a random link for the specified action.
P & S
You will find solutions for your many problems in this library. Here are a few of them.
Problem: In WebForms, when I create a route similar to “Category/Name” and route to a file like “
/Categories.aspx”, which are in different paths, I have to apply server path for each link in page, including image, script and css links.
Solution: LinkFixer implementation is exactly for this issue. No matter in which path the running page is, it finds all links on the page and replaces them with new relative urls according to the current url of the page.
Problem: I want to copy-protect my images. What are my options?
Solution: Well, depending on protection level you need, there are great in-built protections for images. You can disable right click and drag & drop functionality for images.
Problem: I need advanced image protection so users cannot steal images from source code.
Solution: There is ImageSliceProtection which converts your image into pieces of images and replaces all instances of that image on the page with a table of image pieces. This prevents your enemies from developing bot programs for your images. Note that you may need to fix small css issues, since table tag may conflict with your template’s design.
Also ImageWatermarkProtection will easily watermark your images with a single line of code. Slice protection would not work if user simply takes a snapshot of screen, however you can use watermark and slice protection combined to apply highest security for your images.
Problem: I am writing articles on my website and don’t want them to be copied.
Solution: TextSelectionProtection will stop users selecting your text so they cannot copy. However advanced users can get it from source code. You might want to give a look into TextImageConversion, which converts your label control into an image, making impossible to copy the text on your page.
Problem: I want to keep absolute download count for my “program.exe” file. However some users share the path of this file and not the page to download.
Solution: By using LinkProtection, you will get what you want. On your download page, you can easily create a temporary session link and let user download it. This link can only be used on the client once he navigates to download page, so you can keep records of downloads. LinkProtection can be used for many more intentions like single usage or expiring links for music and video files.
Problem: My index page has a very heavy loading with many connections to database. How can I make it faster?
Solution: If your page content does not change too often, PageCaching implementation is perfect for you. Once its registered, it will save content of the page and show it from cache for the specified amount of time without loading.
Problem: Page size is too big. Is there any way to compress page?
Solution: Near using gzip response, you can decrease page size by 20-25% with using WhiteSpaceCleaner. It will simply remove all unneeded space and line return characters from the page and decrease your response page size.
The best part of this library is that it is very easy to customize. See HtmlImplementation class in documentation to learn how to create your own implementation with few lines of code. Instead of tweaking your every pages html or server code one by one, use this library to have your hand on all your pages at once.
Hope you like it.
0 comments:
Post a Comment