0

I am following a tutorial on asp.net web api and mongodb here and on step 4 it talks about dependency injection and adding it to the start.cs in the ConfigureServices() method, however this doesnt seem to exist anymore. My web api templates startup.cs looks something like this...

public partial class Startup
{
    public void Configuration(IAppBuilder app)
    {
        ConfigureAuth(app);
    }
}

So my question is where do I inject my DataAccess class to my web api project as a service? Thanks in advance.

As requested here is my api structure

enter image description here

under LGR.API is the auto generated folders and classes created by visual studios and starting a LGR.Datamodel is my custom class with my api stuff. Really new here... not sure if this correct at all. Feel free to critique with best practices as necessary

2
  • How did you create your Web API template? Commented Nov 8, 2016 at 16:18
  • updated with request Commented Nov 8, 2016 at 16:25

1 Answer 1

1

It looks like you've created an ASP.NET application, and your tutorial is for ASP.NET Core. Recreate your project and pick the "ASP.NET Core Web Application" template.

Sign up to request clarification or add additional context in comments.

5 Comments

Yep, ASP.NET and ASP.NET Core are different things (and yes, it's more confusing that it needs to be). The built-in dependency injection feature your tutorial is using doesn't exist in the older ASP.NET.
@Bean0341 This answer is correct, you're using plain ASP.NET template instead of ASP.NET Core. Follow Step 1 in the tutorial more closely.
I do not have an option for .net core projects... I have VS enterprise do I need update or download something for this?
Ah yeah, you'll need to install the .NET Core tools for Visual Studio. I forgot that it's not built-in, sorry about that! You can grab them here: microsoft.com/net/core#windows You'll also need Visual Studio 2015, not sure which version of Enterprise you have but 2015 Community is a free download.
@Bean0341 Make sure you follow the tutorial closely as it explains what you need to install and where to get it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.