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

Posted by Santosh.Impossible under ASP.NET MVC on 10/17/2014 | Points: 10 | Views : 693 | Status : [Member] | Replies : 1
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


Responses

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

Up
0
Down

Resolved
Try this one: http://www.dotnetfunda.com/articles/show/2385/using-structure-map-in-factory-method-using-factory-pattern

--
Thanks & Regards,
RNA Team

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

Login to post response