Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
 
Add your own
alternative version

HTTP Compression Module

, 19 Mar 2008
A compression module for ASP.NET that works with WebResource.axd, JavaScript, and CSS
CompressionModule.zip
HttpCompress
bin
Debug
DC.Web.HttpCompress.dll
DC.Web.HttpCompress.pdb
obj
Debug
DC.Web.HttpCompress.dll
Refactor
DC.Web.HttpCompress.dll
TempPE
DC.Web.HttpCompress.pdb
Properties
HttpCompressWeb
App_Data
Bin
DC.Web.HttpCompress.dll
DC.Web.HttpCompress.pdb
test
js
App_Themes
MyTheme
favicon.PNG
compressionmoduleold.zip
DC.Web.HttpCompress.dll
DC.Web.HttpCompress.pdb
cache
cache-128213046009839691-D7D3ACCE12AC6EE21F3A2C4853FB330B-gzip.javascript.gzip
cache-128214849328112387-B5AD6B0BF0A02267A16F6E8BF93F8B31-gzip.javascript.gzip
cache-128220044775252020-05454B988893FDC5F7F1FBFD32D5DC37-gzip.css.gzip
cache-128220044775252020-B5AD6B0BF0A02267A16F6E8BF93F8B31-gzip.css.gzip
webResource-632962478152244369-sgQWzX90hPzyZo1xqcGnaUgWtfXwxfhN9aII-2myGJY1-gzip.javascript.gzip
webResource-632962478152244369-vcuzFf2Ilw1XPlD2WrjlQg2-gzip.javascript.gzip
css
javascript
NoCompress
DC.Web.HttpCompress.dll
//Basic Ajax Routine- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated: Jan 15th, 06'
//http://www.dynamicdrive.com/dynamicindex17/ajaxroutine.htm
function ajax()
{
    //var basedomain="http://"+window.location.hostname
    //var soapPost = "";
    var host = window.location.hostname;
    var ajaxobj=createAjaxObj()
    var filetype="txt"
    var addrandomnumber=1 //Set to 1 or 0. See documentation.
    var result;
    var url;
    this.getRequest = getMyAjaxRequest;
    this.postRequest = postMyAjaxRequest;
    this.soapRequest = soapMyAjaxRequest;
    this.getResponse = getMyResponse;
    this.callbackfunction;
    
    function getMyAjaxRequest(url, parameters, callbackfun,filetype)
    {
        this.url = url;
        ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
        if (addrandomnumber==1) //Further defeat caching problem in IE?
            var parameters=parameters+"&ajaxcachebust="+new Date().getTime()
        if (ajaxobj)
        {            
            callbackfunction = callbackfun;
            ajaxobj.onreadystatechange=this.getResponse;
            ajaxobj.open('GET', url+"?"+parameters, true);
            ajaxobj.send(null);
        }
    }
    function postMyAjaxRequest(url, parameters, callbackfun, filetype)
    {
        ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
        if (ajaxobj)
        {
           ajaxobj.onreadystatechange = this.getResponse;
           callbackfunction = callbackfun;
            ajaxobj.open('POST', url, true);
            ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            ajaxobj.setRequestHeader("Content-length", parameters.length);
            ajaxobj.setRequestHeader("Connection", "close");
            ajaxobj.send(parameters);
        }
    }
    
    function soapMyAjaxRequest(url, parameters, callbackfun)
    {
        ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
        if (ajaxobj)
        {
            ajaxobj.onreadystatechange = getSoapResponse;
            callbackfunction = callbackfun;
            ajaxobj.open('POST', url, true);
            ajaxobj.setRequestHeader("Man", "POST " + url + " HTTP/1.1");
            ajaxobj.setRequestHeader("Host", host);
            ajaxobj.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8");
            ajaxobj.setRequestHeader("Content-length", parameters.length); 
            ajaxobj.send(parameters);
        }
    }
    
    function getSoapResponse()
    {
	    var myajax = ajaxobj;
	    var myfiletype = filetype;
	    if (myajax.readyState == 4) 
	    {
	        callbackfunction(myajax.responseText);
	    }

    }
    function getMyResponse()
    {
	    var myajax = ajaxobj;
	    var myfiletype = filetype;
	    if (myajax.readyState == 4) 
		    if (myajax.status==200 || window.location.href.indexOf("http")==-1)
		    {    
			    result = myajax.responseText;
			    callbackfunction(result)
			 }

    }
}

function createAjaxObj()
{
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
    {
        try 
        {
            xmlhttp = new XMLHttpRequest();
        } 
        catch (e) 
        {
            xmlhttp=false;
        }
    }
    if (!xmlhttp && window.createRequest) 
    {
        try 
        {
        xmlhttp = window.createRequest();
        } 
        catch (e) 
        {
            xmlhttp=false;
        }
    }
    return xmlhttp
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

darick_c
Web Developer
United States United States
No Biography provided

| Advertise | Privacy | Mobile
Web02 | 2.8.140826.1 | Last Updated 20 Mar 2008
Article Copyright 2007 by darick_c
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid