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 6111679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:39:30+00:00 2026-05-23T14:39:30+00:00

I am working on an ASP MVC 3 app and I’m writing a custom

  • 0

I am working on an ASP MVC 3 app and I’m writing a custom html helper. It’s nothing special or hugely complex, but it will need an instance of an interface from structure map. I know I can simply call into structuremaps’ object factory from inside the method, but since the rest of the app uses IoC rather than service location I’d like to keep it that way.

Is there a way to inject interfaces into extension methods from inside and asp net mvc app?

UPDATE

An example of what I’m doing might help:

public static class ShowUrl
{
    public static string ForShow(this UrlHelper url, int showId)
    {
        var service = ObjectFactory.GetInstance<IPerformanceService>();

        var showName = service.GetPerformanceTitle(showId);

        return url.Action(MVC.Performance.Details(showId, showName.ToFriendlyUrl()));
    }
}

Which is used like this:

<a href='<%= Url.ForShow(1)%>'>

Essentially I am trying to build a URL with a slug from an entity id. Maybe I’m just going about this in a really daft way.

  • 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-23T14:39:30+00:00Added an answer on May 23, 2026 at 2:39 pm

    There is no way to inject dependencies into an extension method.

    For ASP.NET MVC helpers, you are going to have to do some sort of service location – whether you bury that with some sort of abstraction is up to you.

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

Sidebar

Related Questions

I'm working on a new ASP.NET MVC / JQuery app which will need to
I am working on an existing ASP.NET MVC app that started small and has
I've been working with ASP.NET(WebForm) for a while, but new to ASP.NET MVC. From
I'm working on an ASP.NET MVC App that has buttons that have the server
I am building an ASP.NET MVC 3 app which will run in Azure. Everything
I have an asp.net MVC app that i am working on and I wrote
I have TinyMCE working great in my ASP.NET MVC app except for the spellchecker.
I'm developing an ASP.NET MVC app. I'm working with Syncfusion's PdfDocument (ver 7.303.0.20) in
I'm trying to get an ASP.NET MVC app working... I should have known it
I have an asp.net MVC app in production that very seldom but very consistently

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.