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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:08:42+00:00 2026-05-27T20:08:42+00:00

I am using Ninject in my web application, and as part of this I

  • 0

I am using Ninject in my web application, and as part of this I need some injections to be made in a UrlHelper extension method that resides in a separate assembly. I can’t even get a static reference to the kernel because obviously the library assembly can’t (nor should be) referring to my web application. I know static classes don’t work well with DI, but because I need to use UrlHelper it makes things a little more complicated. How could I rearchitect this? Let me know if you need to see any code or need more information.

  • 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-27T20:08:43+00:00Added an answer on May 27, 2026 at 8:08 pm

    Did you consider a non-static class as DI-friendly wrapper around the static UrlHelper class?

    public class DynamicUrlHelper
    {
      private readonly ISomeDependency dep;
      public DynamicUrlHelper(ISomeDependency dep)
      {
        this.dep = dep;
      }
      public Uri DoMagic(Uri uri)
      {
        return uri.DoMagic(this.dep);
      }
    }
    public interface ISomeDependency
    {
    }
    public static class UrlHelper
    {
      public static Uri DoMagic(this Uri uri, ISomeDependency dep)
      {
        // do it!
        return uri;
      }
    }
    

    You can inject the necessary values into DynamicUrlHelper and inject DynamicUrlHelper anywhere it is needed.

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

Sidebar

Related Questions

i am using ninject in a wcf web service.This web service is hosted in
I have a MVC3 web application. I am using Ninject 2 for dependency injection
I am using the Ninject.Web library with our web forms application. It's working great
I've got a simple web application using ASP.NET MVC3 and Ninject.Web.MVC (the MVC3 version).
I have a web application that uses .NET Framework 4, MVC 4, Ninject 3.
I'm starting a web application with MVC3 and Ninject. There is one dependency that
I'm using Ninject for a desktop application. I'm noticing that if I exit the
I'm using the Ninject.Web.Mvc (the MVC 2 version) add-on with ASP.NET MVC 2. This
I'm creating an application that has a ASP.NET Web API interface using the Self
I have a few classes that are instantiated using ninject Session Scoping - because

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.