【问题标题】:HTTP Error 403.14 in ASP.NET5 MVC6ASP.NET 5 MVC 6 中的 HTTP 错误 403.14
【发布时间】:2015-06-15 08:17:32
【问题描述】:

我只是在使用新的 Visual Studio Community 2015 RC 探索 ASP.NET 5 MVC 6 Web 应用程序。 DotNet 框架 4.6。

我从 nuget 添加了参考 Microsoft.AspNet.MVC (6.0.0-beta4)。然后创建模型、视图和控制器目录。还添加了 HomeController 和一个视图。

这是我的 Startup.cs-

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

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

家庭控制器-

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

但是当我尝试运行项目时,浏览器显示

HTTP 错误 403.14

没有为请求的 URL 配置默认文档。

我需要做任何配置吗?

【问题讨论】:

  • 您能否在 IIS 中找到您的应用程序在哪个应用程序池中运行?
  • @noobed 我怎样才能找到那个?
  • 您检查过与您类似的问题吗? - stackoverflow.com/questions/7880852/…
  • @noobed,也许你不知道他问了什么。

标签: asp.net-core-mvc visual-studio-2015


【解决方案1】:

试试-

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" });
        });
    }

}

【讨论】:

  • 在 RC1 中,当我将 defaults: 添加到 MapRoute 时,我得到 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. 我的控制器上没有任何路由属性,所以我不确定其他默认值在哪里来自...
猜你喜欢
  • 1970-01-01
  • 2015-12-08
  • 1970-01-01
  • 2014-08-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-14
相关资源
最近更新 更多