开发者

log traffic (including posted data) IIS 6.0 - windows server 2003

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 doubl开发者_如何学运维e check whether the data send via wget is actually url encoded.

Thanks!

Best wishes,

Christian


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜