Monday, July 28, 2014

Url Rewrite: Check Request URL Best Practice


Append or Remove the Trailing Slash Symbol



Enforce Lowercase URLs


Checking If a Request Is for a File or a Directory

Using String Functions with Rule Actions and Conditions


Add a note hereURL Rewrite offers three string functions that can be used with the rule actions and conditions:

·         Add a note hereToLower — Returns the string as lowercase.

·         Add a note hereUrlEncode — Returns the string as a URL-encoded format.

·         Add a note hereUrlDecode — Returns the string as a decoded string.

Url rewrite -Restrict Hot Linking Image of Website to be used by other website.

Hot-linking:
URL Rewrite can be also used to prevent/filter other sites from using your website images from their site . Hot-linking can increase traffic to your site , it also a kind of copyright issues.
 
Resolution: We can observe http_referer — the referring website. If it's not your own site, you can assume that it's a hot-link attempt. You must ensure that the domain name matches exactly, so it's wise to precede the hot-linking rule with the Canonical Domain Name rule.

The following example will replace the attempted image with your own image, called prohibited.png. This is  not fullproof solution as it rely on Http_referer as one can never use HTTP_Referer to get away with this.

Add a note here

   

      

      

         

          ^

http://MyWebsite.*" negate="true" />
      

       prohibited.png" />

   
 
By using this, as best practice,
  • we have shielded a security concerns,
  • try to safe guard copyright issue
  • To certain extent performance engineering by reducing unnecessary traffic from unknown sources.

Friday, July 25, 2014

ng-bind, ng-non-bindable, ng-bind-template and class="ng-bind:property"

Index.html

<html data-ng-app="app" id="ng-app" lang="sv">

<head>
 
 

<div data-ng-controller="oControllerA">

<h1>Controller A</h1>

<h2>{{dataObject}}</h2>

<h3>{{dataObject.color}}</h3>

<h3 ng-bind="dataObject.color"></h3>

<h3 ng-bind-template="{{dataObject.color}}"></h3>

<h3 ng-non-bindable>{{dataObject.color}}"</h3>

<h3 class="ng-bind:dataObject.color"></h3>

<input type=" text" data-ng-model="dataObject.color" />

</div>

Angular .Js
var app = angular.module('app', []);
app.factory('ShareService', function () {

return {

dataObject: { color: "Seal" }



}

});
 
app.controller('oControllerA', ['$scope', 'ShareService', function ($scope, ShareService) {



$scope.dataObject = ShareService.dataObject;

}

]);
 

Output

Controller A

{"color":"Seal"}

Seal

Seal

Seal-  ng-bind-template here it can date format.

{{dataObject.color}}" - Ng-non-bindable

Seal


 

Tuesday, July 22, 2014

Angularjs: Directive With $observe and Events

This example helps you understand the working of directive with respect to UI element. One can control the behavior of UI element using directive in AngularJs. There can be many other purpose for which directive can be useful. I could only see directive mostly use to manage UI behavior.

Few important things:

1. We can use thermometer inside div as attribute
2. We can use data-thermometer inside div as mentioned below.
3. We can use attr.observe or attr.$observe





 

Monday, July 21, 2014

AngularJS : Controller Factory Service Example

The sample below code demonstrate use of factory with controller and how we can share data among controllers.

Html Output

Controller A

{"color":"Seal"}

Seal


Controller B

{"color":"Seal"}

Seal


<html data-ng-app="app" id="ng-app" lang="sv">

<head>

<title>Customer App</title>
</head>

<body>
 

<div data-ng-controller="oControllerA">

<h1>Controller A</h1>

<h2>{{dataObject}}</h2>

<h3>{{dataObject.color}}</h3>

<input type="text" data-ng-model="dataObject.color" />

</div>

<div data-ng-controller="oControllerB">

<h1>Controller B</h1>

<h2>{{dataObject}}</h2>

<h3>{{dataObject.color}}</h3>

<input type="text" data-ng-model="dataObject.color" />

</div>
</body>

</html>

CustomerController.js


var app = angular.module('app', []);

app.factory('ShareService', function () {

return {

dataObject: { color: "Seal" }



}

});
 
app.controller('oControllerA', ['$scope', 'ShareService', function ($scope, ShareService) {



$scope.dataObject = ShareService.dataObject;

}

]);
 
app.controller('oControllerB', ['$scope', 'ShareService', function ($scope, ShareService) {



$scope.dataObject = ShareService.dataObject;

}

]);
 
 

Friday, July 18, 2014

Http.sys Cache · UriScavengerPeriod. Default value: 120 seconds.

· UriScavengerPeriod. Default value: 120 seconds.

Important Registry Setting for production IIS web server environment.
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Http\Parameters


Below description do not belong to me..

I referred below blog :
http://performance-expert.blogspot.se/2012/06/high-performance-websites-stanford.html

The http.sys cache is periodically scanned by a scavenger, and entries that are not accessed between scavenger scans are removed. Setting the scavenger period to a high value reduces the number of scavenger scans. However, the cache memory usage might increase because older, less frequently accessed entries can remain in the cache. Setting the period too low causes more frequent scavenger scans, and it can result in too many flushes and cache churn

IIS Performance Tuning : allowSubDirConfig="false"

As a best practice , never allow nested web.config for single website. Avoid using multiple web.config as applicationhost.config try to make traversal search to locate web.config. As a best practice there should be one web.config.

Changes in Applicationhost.config 
    
     
    
            
    

        
    
 
Remove unnecessary module such windows authentication , if web site is open to all web users.