Blog

  • Matching MD5 hashes in ASP.NET and ASP Classic

    The goal of this page is to put two MD5 code samples on the same web page, one for ASP classic and one for ASP.NET. String formatting (like ASCII vs UTF-8) can trip up coding these two routines. These two code samples will produce the same MD5 hash output.

    Classic ASP/VBScript MD5

    The ASP code is simple once you have a copy of md5.asp from http://frez.co.uk. The only file in the ZIP that you need is md5.asp.


    <!--#include file="md5.asp"-->
    <% response.write md5("[email protected]") %>

    ASP.NET MD5

    The keys to getting the .net output to match are encoding.ascii and toString("x2").

    <%@ Import Namespace="System.Security.Cryptography" %>   
    <script language="VB" runat="server">
    
    	Public Sub Page_Load( sender As Object, e As EventArgs )
    
    		Dim strPlainText as String = "[email protected]"
      		
    		dim md5Hasher as MD5 = MD5.create( )
    		
    		dim result as byte( ) = md5Hasher.computeHash( encoding.ascii.getBytes( strPlainText))
    		
    		for each singleByte as byte in result
    			response.write ( singleByte.ToString("x2") )
    		next
    		
    	End Sub
    
    </script>
    

  • aspSmartUpload.dll usage


    aspSmartUpload.dll Q&A

    1. Frequently asked questions
    2. IIS7 installation and configuration
    3. Registry key and properties
    4. Troubleshooting errors
    5. Downloads and official documentation
    What is aspSmartUpload.dll?
    A 32-bit library to facilitate file uploads via ASP Classic and IIS.
    Will aspSmartUpload.dll work on Windows Server 2008 64 bit with IIS7?
    Yes.

    IIS7 Installation and configuration

    1. Install at C:\Windows\SysWOW64\
    2. Register the DLL via command prompt: regsvr32 C:\Windows\SysWOW64\aspSmartUpload.dll
    3. Enable 32-bit applications on the website’s application pool

    IIS7 considerations:

    • Mind the Maximum Requesting Entity Body Limit property, a member of the Limits Properties under the ASP icon of the website profile in IIS7. The maximum file size is limited by the request object to the number of bytes set there. You may log 500 errors with a description of, ASP 0104 : 80004005 Operation not Allowed, Request object if the file sent with the request is bigger than the set limit.
    • Another Limit Property controls the amount of time the server allows ASP requests to complete. The Script Time-out property defaults to one minute thirty seconds.
    Can this DLL upload files to another Server 2008 in the same domain?
    Yes. Change the user account that handles Anonymous Access in the Authentication section of IIS7 to Application Pool User. Use a UNC path in your call to mySmartUpload.Save.

    Errors

    If you do not have the ability to IIS reset or reboot the server that holds this DLL, your life may be miserable. I have been using this DLL for years, and sometimes the only way to prevent aspSmartUpload.dll from erroring is to restart the machine.

    ASP 0104 : 80004005 Operation not Allowed, Request object
    Configuration prevents file size. Adjust the IIS7 Limit Properties.
    error: -2146778286 Server.CreateObject Failed, 800ac352 Server object
    True story: one day I could not escape these errors until I rebooted the Windows machine. Restarting the IIS service may also work (iisreset /NOFORCE at a command prompt).
    error: -2147024882 Server.CreateObject Failed, 8007000e Server object
    Make sure the DLL is registered and in the proper location.
    Unable to save file (Error 1120)
    This could be permissions on the folder for the Internet Guest Account. However, I had to reboot the server containing the upload script to stop this error. My setup is the script runs on one server and the files are saved on another. I believe the server where the files were saved was not found during boot up (because it was also rebooting) and so the save directory was unavailable.
    Where is the registry key?
    HKEY_LOCAL_MACHINE\SOFTWARE\Advantys\aspSmartUpload

    Key properties:

    1. TotalMaxFileSize
    2. MaxFileSize
    3. AllowedFilesList
    4. DeniedFilesList
    5. DenyPhysicalPath

    How to modify these properties in code:

    	dim mySmartUpload
    	set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
    	mySmartUpload.TotalMaxFileSize = 8388608
    	mySmartUpload.MaxFileSize = 2097152
    	mySmartUpload.AllowedFilesList = "jpg,jpeg,png"
    	mySmartUpload.DeniedFilesList = "bat,exe,com,asp"
    	mySmartUpload.DenyPhysicalPath = False
    		

    Read more details about these properties here.

    Downloads & documentation

    These files were distributed more then 10 years ago by Advantys, the makers of the DLL.

    1. aspsmartupload_v3_3.zip
    2. aspsmartupload_samples.zip