views:

20

answers:

1

Hi,

I understand that IIS logs parts of http request which I can access. I would like to log the whole http request for a short period of time. This means I would like to store the data being posted in its raw form. Is this possible using ISS’s logging facility or do I have to install another tool?

I have the following problem. I expose a ‘restful web service’ via asp.net mvc which stores posted data in a relational database. I tested the service via javascript. I url encoded some data and post them using jquery. The data is stored url encoded in the database as expected. Some clients also post data using unix and wget to the same web service. Unfortunately, the data is not stored url encoded (so we lose some data if it contains special characters like &). They claim that they send the data url encoded. Can this be a case true? Is the mechanics of wget post different to that of a javascript post? Is there a layer I overlook? I would like to double check whether the data send via wget is actually url encoded.

Thanks!

Best wishes,

Christian

A: 

You could create an MVC action filter, you could then have access to the Request object and pull out the interesting bits. You could then store this information in a text file or logging database. I've used this approach before and it works well if you thread the saving to database operation to not slow down the general request operation.

public class LogRequest : ActionFilterAttribute, IActionFilter
{
    #region IActionFilter Members

    void IActionFilter.OnActionExecuting(ActionExecutingContext var)
    {
    //code goes here
    }

    #endregion
}


   [AcceptVerbs(HttpVerbs.Get)]
    [LogRequest()]
    public ActionResult Index()
    {
        return View();
    }

You've kind of asked two questions here, I don't know about the second part.

Phil
Thanks I was thinking about that but I was looking for something to view the traffic (including the posted data) before it hits IIS/ASP.NET. It seems as if some layer automatically url decodes the data before it hits iis. Does this makes sense? Sorry if my question wasn't clear enough
csetzkorn
Might want to try a question site like serverfault then, stackoverflow is for programming questions. I don't know much about IIS logging or server programs to do that.Perhaps running WireShark on the server would enable you to sniff the packets?
Phil

related questions