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

Generating Unique Strings in NET

Approach 1:

String s1 = Guid.NewGuid().ToString();
String s2 = Guid.NewGuid().Tostring("N");
String s3 = Guid.NewGuid().ToString("P");
String s3 = Guid.NewGuid().ToString("D");

Approach 2:

String s1 = System.IO.Path.GetRandomeFileName();
String s2 = System.IO.Path.ChangeExtension(System.IO.Path.GetRandomFileName(),null);

Comparison or the 2 Approaches:
1. Approach1 generates at least 32 characters (0-9 and a-f) letters only.
Hint: larger size on the database, absolutely unique.
2. Approach2 Generates at least 8 characters (0-9 and a-z) letters.
Hint: Good for Captcha, less size on the database,  might have duplicates