3

I am just exploring ASP.NET 5 MVC 6 web app with new Visual Studio Community 2015 RC. DotNet framework 4.6.

I've added reference Microsoft.AspNet.MVC (6.0.0-beta4) from nuget. Then created Models,Views & Controllers directory. Also added HomeController and a view.

Here is my Startup.cs-

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

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

Home Conctoller-

public class HomeController : Controller
{
    public IActionResult Index()
    {
        return View();
    }
}

But while i try to run the project, browser shows

HTTP Error 403.14

A default document is not configured for the requested URL.

Do I need to do anything to configure?

s.k.paul
  • 7,099
  • 28
  • 93
  • 168

1 Answers1

3

Try-

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

    public void Configure(IApplicationBuilder app)
    {
        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller}/{action}/{id?}",
                defaults: new { controller = "Home", action = "Index" });
        });
    }

}
Code It
  • 396
  • 1
  • 6
  • in RC1, when I added the `defaults:` to `MapRoute`, I am getting `System.InvalidOperationException: The route parameter 'controller' has both an inline default value and an explicit default value specified. A route parameter cannot contain an inline default value when a default value is specified explicitly. Consider removing one of them.` I don't have any routing attributes on my controller, so I am not sure where the other defaults are coming from... – Optimax Nov 30 '15 at 23:29