tags:

views:

48

answers:

1

hi, i am working on wcf rest. i would like to do the following tracking work.

  1. track the user Real ip address
  2. track from where did the user came from ?i know i can use the referer header but since this is something very common task which most of the people do it would be better if some code is provided.in short i want to do the campaining work in this step.
  3. i would be working on cookies , is there any library which can help me on the server side parsing the cookie field ? thanks

P.S i cannot enable AspNetCompatibilityRequirements.because my service is performance sensitive.

A: 

For common tasks for all requests, I would look into custom HTTP Module.

An HTTP module is an assembly that is called on every request made to your application. HTTP modules are called as part of the ASP.NET request pipeline and have access to life cycle events throughout the request. HTTP modules therefore give you the opportunity to examine incoming requests and take action based on the request. They also give you the opportunity to examine the outbound response and modify it.

ASP.NET HTTP modules are similar to ISAPI filters in that they run for all requests. However, they are written in managed code and are fully integrated with the life cycle of an ASP.NET application.

Typical uses for HTTP modules include:

  • Security. Because you can examine incoming requests, your HTTP module can perform custom authentication or other security checks before the requested page, XML Web service, or handler is called.

  • Statistics and logging. Because HTTP modules are called on every request, you can gather request statistics and logging information in a centralized module, rather than in individual pages.

  • Custom headers or footers. Because you can modify the outbound response, you can inject content such as custom header information into every page or XML Web service response.

eed3si9n
as i said , i am on wcf rest with AspNetCompatibilityRequirements disabled because it causes performance issues.i was asking how can i access server variables (REMOTE_ADDR) without that option enabled .
Muhammad Jamal Shaikh