Friday, 30 March 2007

Using WFetch to debug your HTTP connection

This is a really handy tool for debugging http request and response data if you wish to go a bit lower level than pressing F5 on the browser.

You have the ability to create custom header and body request items which is also perfect for tuning your SOAP messages.

Thursday, 29 March 2007

Using session state in an .asmx web service

You are building an ASP.NET web service and wish to expose some functionality that relies on session state information. A standard .aspx page will handle session state normally but web services do not have acess to the same session data as the rest of your applicaiton.

The trick is that in order to access session state information within a web method you must enable session state management explicitly in your .asmx file as follows:

[WebMethod(EnableSession = true)]

By specifying the EnableSession value you will have a managed session to play with. If you dont set this value the Session object will be null and you will encounter an object reference exception when trying to access the Session object from either this.Session or System.Web.HttpContext.Current.Session.

Friday, 23 March 2007

Quickly setting up SSL under IIS with SelfSSL

Its fairly easy to setup https functionality when you're running an Apache web server however when trying to do the same thing in IIS you will encounter the problem of generating a certificate and having to rely on a Certification Authority such as Verisign or your own certification server to have the certificate authorised.

This problem is easily solved with Microsoft SelfSSL utility, which can be downloaded here. It will only install under XP or Windows 2003 however you can copy the SelfSSL.exe file directly into a 2000 computer and run it without a problem.

A typical command option you can run (this will give you a certificate valid for 120 days) is:

selfssl.exe /N:CN=(computername) /K:1024 /V:120 /S:1

And thats it! This will take care of the certificate generation and installation. Watch out if you are running multiple Web Sites under the one server as you will have to fiddle with the /s tag to point the SSL certificate in the right direction.