Share via


MEF and ASP.NET MVC sample updated

Sample updated to Preview 6. I've also took the time to simplify the MvcCatalog and to hard set the Creation Policy to Non Shared for all controllers.

Have fun! 

MvcWithMEF.zip

Comments

  • Anonymous
    August 03, 2009
    Excellent! Was looking for a sample that worked around the (now) obsolete metadata in the GetExports function (CreateController).

  • Anonymous
    November 18, 2009
    Thank you for the article and sample code.  I'm feeling my way through it.  I noticed the views in your Extensions class are not strongly typed.  Instead, you are populating ViewData dictionary using magic strings: ViewData["forums"] = _forumService.GetEnabledForumsRecentActivity(); Can we use strongly types views in the Extension classes?  I hates using magic strings and dictionaries I do.  Anyways, thanks for your efforts.

  • Anonymous
    May 14, 2010
    Great code, that is what i was looking for. But it seems, that it doesn't work with MVC 2 and MEF Net 4.0 I get the following error message after refreshing a page: A single instance of controller 'xxxController' cannot be used to handle multiple requests. If a custom controller factory is in use, make sure that it creates a new instance of the controller for each request. GetExports() does not return a new instance, even if the controller is decorated with [Export, PartCreationPolicy(CreationPolicy.NonShared)]. Is there any workaround for this, i would like to use this approach so much in my current project. Thanks a lot.

  • Anonymous
    May 25, 2010
    @Tom, I'm sure you can. It should work as it's no correlation with MEF. Thanks

  • Anonymous
    June 16, 2010
    I agree with Tom, it doesn't work when the view is strongly typed...any ideas?

  • Anonymous
    June 16, 2010
    Did you try with the very latest version of the sample?

  • Anonymous
    October 20, 2010
    How to add another function to controler (wiki ext. as  sample) public ViewResult RSVPForm() {            return View(ViewRoot + "RSVPForm.aspx"); } and then call it in index.aspx  <%= Html.ActionLink("Go to reg form", "RSVPForm")%> Thanks, and sorry for my bad english

  • Anonymous
    October 25, 2010
    Hi, thank you for the good article :) I have one question. How i can change plugin loader to force it load plugins without add reference to main web app. When i change var assembly = Assembly.LoadFrom(fileName) to  Assembly.LoadFile i got some trouble with partial view in Forum plugin... Thanks a lot