ASP.NET - Adding a Service to an ASP.NET Core Website [4 of 13]

Play ASP.NET - Adding a Service to an ASP.NET Core Website [4 of 13]

The Discussion

  • User profile image

    This code blows up when I enter it. It has no idea what IWebHostEnvironment is, it's underlined and I can't find any documentation, I have all the using statements you have but nothing's working! :(

  • User profile image
    I added the "Microsoft.AspNetCore.Hosting" Nuget, still it's showing "IWebHostEnvironment" could not be found. I am using VS2019 community. Is there any work around?
  • User profile image
    @Niner838598: IWebHostEnviornment only works for ASP.Net 3.0. Make sure you have VS2019 and the solution is targeting ASP.Net 3.0(Last time I checked it does not support VS2017).
  • User profile image
    This is really lame because nobody is going to use a static json file. So, when you try to create a service with an entities model the code will be so different that this is totally useless. Microsoft is making the same mistake they made over a decade ago with their ASP.Net tutorials that would always say something like "you could use a database but for the purpose of this demo I will just use some static data" then when someone decides to use a database they have to do a lot of work that the tutorial does not help with, so in an effort to save time they create more time.

    For instance there is no option to create a CRUD service file from the entities model like there is for a CRUD razor page or CRUD controller, so to have a service at all you will have to find a solution yourself.

Add Your 2 Cents