I’ve done a lot of web services during the last couple of years and I simply love Service Oriented Architecture using SOAP. The power of using services as a means to create large connected systems are enormous but sometimes it can be a performance bottleneck.

The SOAP protocol in ASP.NET is defined as a response/request operation even if the method returns a void type. That means that the requesting client waits until it gets a response from the web service and that can take a relative long time. For simple logging applications or other simple SOAP calls where you aren’t interested in waiting for the response, you can achieve performance gains by using the SoapDocumentMethod attribute on the web service methods.

What it does is that it instantly returns HTTP status code 200 OK to the requesting client, so it doesn’t have to wait for the entire request to finish processing and it’s built directly into the ASP.NET engine. Here is how to do it:

[WebMethod, SoapDocumentMethod(OneWay = true)]

public void LogError(string errorMessage)

{

  DoSlowOperation(errorMessage);

}

It’s not exactly rocket science but it can remove a potential bottleneck.

Whenever I had to add a string to a web controls control collection I’ve always used the Literal control like this:

Literal str = new Literal();

str.Text = "hello world";

Page.Controls.Add(str);

I have always thought a Literal was too cumbersome to use for a simple thing like adding a string to a controls control collection. Then, the other day, I found the LiteralControl while browsing through the MSDN docs and that my friends are a real treat. It lives in the System.Web.UI namespace and it adds great value. You can use it to achieve the same task as the one above, but in a more natural way.

>

Page.Controls.Add(new LiteralControl("Hello world"));

It’s much cleaner, much nicer and much simpler. Now I can’t live without it.