I am trying to implement Dependency injection using structuremap in a asp.net mvc2 application for global filters. Since asp.net mvc2 does not have the feature to support global filters and there is no scope for the project to migrate it to asp.net mvc3 , I went with using Fluent Filters using the below url: http://www.codeproject.com/Articles/125074/Fluent-Filters-Global-Action-Filters-for-ASP-NET-M
But the sample mentioned in the above url is using Unity framework. I tried a lot to implement it using structuremap framework since the project is using structuremap but I am facing issues with the approach.
Code is mentioned below:
BrowserDetectionFilter.cs --> Global filter needed to be used across the application.
public class BrowserDetectionFilter: IResultFilter
{
#region IResultFilter Members
public void OnResultExecuted(ResultExecutedContext filterContext)
{
StringBuilder result = new StringBuilder();
result.Append("<div style=\"width:200px; border:1px #fff solid;color:#fff;margin:0 auto;padding:5px;\">");
result.Append(string.Format("<div><b>Browser Type</b>: {0}</div>", filterContext.HttpContext.Request.Browser.Browser));
result.Append(string.Format("<div><b>Version</b>: {0}</div>", filterContext.HttpContext.Request.Browser.Version));
result.Append("</div>");
filterContext.HttpContext.Response.Write(result.ToString());
}
public void OnResultExecuting(ResultExecutingContext filterContext) {}
#endregion
}
I want to implement Dependency Injection using structuremap in the asp.net mvc2 project.
Can anyone help me with some code sample regarding the approach?
santosh kumar patro