Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4059280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:11:17+00:00 2026-05-20T15:11:17+00:00

I am following this excellent article in order to create my own attribute in

  • 0

I am following this excellent article in order to create my own attribute in the mvc.net framework v2 .
The Author , Simone Chiaretta, uses Ninject to inject dependency within an ActionFilter using the attribute [Inject] over the dependencies he has in his class.

I would like to know if the same kind of technics might be used with structuremap.

I hope to have given enough details, if not please ask.. 😉

yours,

UPDATE 1:

Here is some code to enlighten a bit my problem

public class GreetingAttribute :
ActionFilterAttribute,
ISuperActionFilter,IGreetingAttribute
{
    **[Inject]**
    public IGestioneUtenti _service { get; set; }

    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        _service.Elenca();
        base.OnActionExecuting(filterContext);
    }

    public override void OnActionExecuted(ActionExecutedContext filterContext)
    {
        ViewResult result = filterContext.Result as ViewResult;
        _service.Elenca();

        if (result != null)
        {
            result.ViewData["Title"] += " - " ;
        }
    }
}

I would have loved to be able to have this [Inject] attribute. So that my InvokeActionMethodWithFilters would have looked like this :

protected override ActionExecutedContext InvokeActionMethodWithFilters(
    ControllerContext controllerContext, IList<IActionFilter> filters,
    ActionDescriptor actionDescriptor, IDictionary<string, object> parameters) 
{
    foreach (IActionFilter actionFilter in filters)
    {
        ISuperActionFilter superActionFilter = 
            actionFilter as ISuperActionFilter;
        if (superActionFilter != null)
        {
            ObjectFactory.DoInjectionForMarkedAttribute(actionFilter);
        }

    }
    return base.InvokeActionMethodWithFilters(
        controllerContext, filters, actionDescriptor, parameters); 
}

Below my final implementation in an answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:11:18+00:00Added an answer on May 20, 2026 at 3:11 pm

    The SetterProperty attribute is equivalent to Ninject’s Inject.

    Also, take a look at this blog post: http://codebetter.com/jeremymiller/2008/10/09/setter-injection-in-structuremap-2-5/ for more details on setter injection in Structuremap. Unfortunately Some of the examples use an older syntax , but all the ideas apply.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following this tutorial (http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/handling-concurrency-with-the-entity-framework-in-an-asp-net-mvc-application), I learned how to save data and do concurrency checks
I'm following this excellent article to setup the authentification part of my rails (3.2)
After following this MVC 4 tutorial series I was trying some of the stuff
I read this excellent article and it make sense: Java is strictly pass by
Following on from the excellent answer to my previous question: Linq Entity Framework generic
I was reading this excellent article which gives an introduction to Asynchronous programming here
I've been following along with this excellent asio tutorial , but have got confused
I was about to deploy WordPress on Microsoft Azure Cloud following this excellent blog:
I've been following Miguel Castro's excellent article on WCF here and it's all working
I was following Bruno's excellent article for one-to-one mapping in fluent Nhibernate. However I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.