How to use structuremap for implementing Fluent Filters in mvc2 for managing the dependency? [Resolved]

Posted by Santosh.Impossible under ASP.NET MVC on 10/17/2014 | Points: 10 | Views : 606 | Status : [Member] | Replies : 1
I am trying to implement Dependency injection using structuremap in a mvc2 application for global filters. Since mvc2 does not have the feature to support global filters and there is no scope for the project to migrate it to mvc3 , I went with using Fluent Filters using the below url:

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));


public void OnResultExecuting(ResultExecutingContext filterContext) {}

I want to implement Dependency Injection using structuremap in the mvc2 project.

Can anyone help me with some code sample regarding the approach?

santosh kumar patro


Posted by: Rajnilari2015 on: 4/28/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50


Try this one:

Thanks & Regards,
RNA Team

Santosh.Impossible, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response