Archive

Posts Tagged ‘http’

Sample JSON HTTP Headers for POST Request

February 22nd, 2010

This is a note to self more than anything for the bear minimum http headers of sending a JSON request.

POST: /Services/OutwardFacingService.asmx/GetList
Host: testserver.co.uk
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Content-Type: application/json
Content-Length: 36

Post Content:
{ "LastModifiedSince":"01/01/2010" }

Techie , ,

FormRewrite.dll

July 7th, 2006

For those of you who love dabbling with rewriting URLs, you have most probably become aware that Dot Net 2.0+ handles postbacks and viewstates differently to Dot Net 1.x. The action attribute within the form tag sends postbacks back to the physical page, and not the rewritten page, causing a viewstate validation error due to the tighter security of the second framework.

This is not a big problem however. To solve this, all we need to do is rewrite the location of the action attribute to the rewritten url. If you can do this, great, but an easier solution is to leave the action attribute blank, which has the effect of sending the form back to the same page - Excellent, that’s what we want, with hardly any effort. ;)

Firstly download FormRewrite.dll and place in your bin directory (Legacy - Currently unavailable)

Secondly we need to rewrite the form’s action attribute; place this code into every page that is rewritten and perform postbacks. If you use master pages, place it in there instead.

Add to the first line of your file

Imports Denaploy.Sys.Rewrite

And this within your class

  Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
    writer = New FormRewrite(writer, " ", HttpContext.Current.Items("VirtualPath"))
    MyBase.Render(writer)
  End Sub

Techie ,

Configuation of GZip Compression in IIS6

July 27th, 2005

GZip is automatically turned off in IIS by default, but could save on bandwidth dramatically and also cause a decrease in page load time from clients. And if your worried about all your dynamic content, it’s actually easier to compress this then static. Well, they both have their up’s and downs.

Dynamic content is compressed on the fly, which means extra cpu load for each request. If your server is not under load then there is no problem. Even if it is under load, you can still change the compression levels.

Compression Levels

Compression Levels can be set within the “MetaBase.xml” file (for IIS 6+). If you search for GZip within this file, you should be able to locate and change the relevant options. Remember to change both GZip and Deflate, for both dynamic and static.

The values range from 0 (Minimum) to 10 (Maximum)

The default is set to 0, which does enable a good compression at very little performance cost (60-80% compression is not uncommon), but if you do have the extra power, 9 offers the best compression versus cpu load. A word of warning however, level 10 dramatically increases load with little or no gain in compression.

Static Content

To set your static files, simply add the file extensions to the end of the GZIP and DEFLATE commands.

When a request is made, it first checks the temporary directory to see if it has a compressed copy, which it returns. If not, it sends the original file to the client, then compresses the file and saves it for future requests. The maximum directory size can be specified within the IIS manager.

Within Inetpub\AdminScripts\

cscript adsutil.vbs SET W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "js" "css"

cscript adsutil.vbs SET W3Svc/Filters/Compression/Deflate/HcFileExtensions "htm" "html" "js" "css"

iisreset

Dynamic Content

In my view dynamic is simpler as it is done on the fly. Again, simply add all the dynamic extensions you use for execution.

Within Inetpub\AdminScripts\

CSCRIPT ADSUTIL.VBS SET W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "aspx"

CSCRIPT ADSUTIL.VBS SET W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx"

iisreset

Techie ,