Hi!
I'm trying to use @inject to inject via .netCore DI system some services in my View.
But "@inject" it's not a known tag in RazorLight.
Can you implement this in some future version? Do you want some help to do this?
To now I use a workaround.
Rather than
@inject IServiceUri ServiceUri
I used
@{var ServiceUri = new ServiceUri();}
But... I lost DI :'(
@inject is a feature of ASP.NET MVC, but I planned to add an integration
Expect this on beta5 release
Add package
Install-Package RazorLight.MVC
public void ConfigureServices(IServiceCollection services)
{
....
services.AddRazorLight("/Views"); // <- This one
....
}
@inject MyProject.TestViewModel myModel
Hi @toddams Looks like that the MVC package has been depreciated. But I still have the same issue. Would you recommend to use that anyway? Thanks
Hi @toddams I'm using the library in a net standard class library and I wanted to use the inject feature but it doesn't work, any recommendation how I can get that working?
@KishorTiwari @lnodaba
Hello. As i understand framework realization, you cannot use base user scenario for using @inject .
But what you should do:
First way:
Expand your services collection: services.AddRazorLight()
In controller or service constructor get IRazorLightEngine service, and use it for your tasks.
Another way:
You can use example from Tests, method Ensure_Registered_Properties_Are_Injected
Most helpful comment
Add package
Install-Package RazorLight.MVC