.NET Core MVC RRS feed

  • Question

  • Hi,

    I have a service (service1) that is added to dependency injection as a singleton class at the start up (startup.cs). I am also implementing IViewLocationExpander (BrandLocationExpandor) in order to do some View location management. I need service1 that is injected at the startup to be available in the BrandLocationExpandor. How can I inject this as I cannot inject it like in a controller and I have the following in the startup.cs

      services.AddSingleton<IService1, service1>();

     services.Configure<RazorViewEngineOptions>(options =>
                    options.ViewLocationExpanders.Add(new BrandLocationExpander());

    Is there any way I can inject service1 into the above new BrandLocationExpander()

    Many thanks


    Thursday, May 10, 2018 7:12 AM

All replies

  • Hi StockDev,

    Thank you for posting here.

    According to your question is more related to MVC, please post a new thread in MVC forum for suitable support.

    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework, including Managed Extensibility Framework (MEF), Charting Controls, CardSpace, Windows Identity Foundation (WIF), Point of Sale (POS), Transactions.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 11, 2018 7:05 AM