Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET 5 on Visual Studio 2015 addMvc method not found

I am following this tutorial: http://www.asp.net/vnext/overview/aspnet-vnext/create-a-web-api-with-mvc-6 to setup a web api and I have not made it very far. Once I added the line: services.addMvc(); I got an exception saying this method is not found. I searched online and found a separate question/answer here: http://forums.asp.net/t/2026087.aspx but that did not help.

My startup.cs looks like this:

public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();
    }

    public void Configure(IApplicationBuilder app)
    {
        app.UseMvc();

        app.UseWelcomePage();
    }

And my project.json:

{
"webroot": "wwwroot",
"version": "1.0.0-*",
"exclude": [
    "wwwroot"
],
"packExclude": [
    "node_modules",
    "bower_components",
    "**.kproj",
    "**.user",
    "**.vspscc"
],
"dependencies": {
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta2",
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta1",
    "Microsoft.AspNet.Mvc": "6.0.0-beta1"
},
"frameworks" : {
    "aspnet50" : { },
    "aspnetcore50" : { }
}
}
like image 225
girlcode Avatar asked Feb 11 '23 02:02

girlcode


1 Answers

Mostly sure you are using some incorrect packages. Try to create the default starter application that comes with VS (use the latest VS 2015) and see exactly what packages to use.

A few comments based on the contents of yourproject.json file:

  1. For now, do not mix different versions of beta packages (like beta1 and beta2). That's a recipe for disaster :)
  2. Beta1 is old, please upgrade
like image 182
Victor Hurdugaci Avatar answered Feb 13 '23 21:02

Victor Hurdugaci