Allowing .exe files to be download in IIS7 and IIS8.

To Allow executable files to be download by the client just add the following configuration to web.config file.

<add name="StaticFile" path="*.exe" verb="*" modules="StaticFileModule" resourceType="File" />

Dumping Binary Content Field value into File

Here is a quick way to dump an image(binary) field value into a file:

SET @SQL = 'bcp "select [binaryfield] from [database]dbo.[table] where field = " queryout "c:\temp\output.jpg" -T -n -S ' + @@ServerName
EXEC xp_cmdshell @SQL

bcp => Bulk Copy Program (a utility that installs with SQL Server and can assist with large data transfers)

-T => Trusted Connection
-n => Native Type
-S => Server/Instance name

for more info on bcp type
bcp /? on command line

Detect IE10 using JavaScript

Here are possible ways to detect IE10 browser using Javascript:

Though the following aren’t perfect solution it could be a better start.

Method 1:

var ie10 = (navigator.userAgent.match(/Trident\/[6]/i));

Method 2:

var ie10 = (navigator.userAgent.match(/MSIE 10/i));

Method 3:

<!--[if (gt IE 9)]><script type="text/javascript">window.ie10 = true;</script> <![endif]-->

<script type=”text/javascript”>
document.write(‘IE 10 detected.’);
document.write(‘Browser is NOT IE10.’);

Extracting Text Between Words(Pattern) using Regex in JavaScript

Below are the ways to extract text between words in javascript:

Given the String “Name: John Berkins Address: LA, USA”

	var data = "Name: John Berkins Address: LA, USA";
	//using String.indexOf + String.substring
	var name = data.substring(data.indexOf("Name:")+6,data.indexOf("Address"));
	var addr = data.substring(data.indexOf("Address:") + 9);

	//using Regex (with the use of Non-Capturing Group(?:)
	var rname = data.match(/(?:Name:)(.+)(?:Address:)/)[1];
	var raddr = data.match(/(?:Address:)(.*)/)[1];
	//Note: the regex  code above may not work if the data contains \n (newline character)
	//      this is because of the (.+) expression cannot disregards \n chars,
	//      the workaround is to change it to anoter expression or to remove the \n char before
	//		the extraction process: h
	//data = data.replace(/\n/g,' ');
	//var rname = data.match(/(?:Name:)(.+)(?:Address:)/)[1];
	//var raddr = data.match(/(?:Address:)(.*)/)[1];