title: Internal Server Error while running a simple .Net Core MVC application on Ubuntu 16.04
body: <p>I am getting an internal server error while running a simple "hello world" application using .Net core 1.0 on Ubuntu. I'm sure that I'm missing something simple, but can't figure out what it is. It was working until I replaced <code>return Content("Hello, world!");</code> with <code>return View();</code> in HomeController, and added <code>using System.IO;</code> and <code>.UseContentRoot(Directory.GetCurrentDirectory())</code> to Program.cs.</p>
  
  <p>I have tried adding <code>System</code> and <code>System.X</code> to my list of dependencies in Startup.cs to no avail. </p>
  
  <h2>Program.cs</h2>
  
  <pre><code>using Microsoft.AspNetCore.Hosting;
  using System.IO;
  
  namespace aspnetcoreapp
  {
      public class Program
      {
          public static void Main(string[] args)
          {
              var host = new WebHostBuilder()
                  .UseKestrel()
                  .UseContentRoot(Directory.GetCurrentDirectory())
                  .UseStartup&lt;Startup&gt;()
                  .Build();
  
              host.Run();
          }
      }
  }
  </code></pre>
  
  <h1>project.json</h1>
  
  <pre><code>{
    "version": "1.0.0-*",
    "buildOptions": {
      "debugType": "portable",
      "emitEntryPoint": true
    },
    "dependencies": {
      "Microsoft.AspNetCore.Diagnostics": "1.0.0",
      "Microsoft.AspNetCore.Mvc": "1.0.0",
      "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
      "Microsoft.AspNetCore.StaticFiles": "1.0.0",
      "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0" }
    },
    "frameworks": {
      "netcoreapp1.0": {}
    }
  }
  </code></pre>
  
  <h1>Startup.cs</h1>
  
  <pre><code>using Microsoft.AspNetCore.Builder;
  using Microsoft.Extensions.DependencyInjection;
  
  namespace aspnetcoreapp
  {
      public class Startup
      {
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddMvc();
          }
  
          public void Configure(IApplicationBuilder app)
          {
              app.UseDeveloperExceptionPage();
  
              app.UseStaticFiles();
  
              app.UseMvc();
          }
      }
  }
  </code></pre>
  
  <h1>HomeController.cs</h1>
  
  <pre><code>using Microsoft.AspNetCore.Mvc;
  
  namespace aspnetcoreapp
  {
      [Route("/")]
      [Route("[controller]")]
      public class HomeController : Controller
      {
          public IActionResult Index()
          {
              return View();
          }
      }
  }
  </code></pre>
  
  <h1>dotnet run</h1>
  
  <pre><code>Project aspnetcoreapp (.NETCoreApp,Version=v1.0) will be compiled because inputs were modified
  Compiling aspnetcoreapp for .NETCoreApp,Version=v1.0
  
  Compilation succeeded.
      0 Warning(s)
      0 Error(s)
  
  Time elapsed 00:00:01.0784778
  
  
  Hosting environment: Production
  Content root path: /home/cvandal/code/aspnetcoreapp
  Now listening on: http://localhost:5000
  Application started. Press Ctrl+C to shut down.
  </code></pre>
  
  <h1>Result</h1>
  
  <blockquote>
    <blockquote>
      <p>An error occurred during the compilation of a resource required to process this request. Please review the following specific error
      details and modify your source code appropriately.</p>
    </blockquote>
    
    <p>Generated Code</p>
    
    <p>The type or namespace name 'System' could not be found (are you
    missing a using directive or an assembly reference?)
        using System; The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
        using System.Linq; The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
        using System.Collections.Generic; The type or namespace name 'ViewFeatures' does not exist in the namespace
    'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)
        using Microsoft.AspNetCore.Mvc.ViewFeatures; The type or namespace name 'System' could not be found (are you missing a using directive or
    an assembly reference?)
        using System.Threading.Tasks; Cannot define a class or member that utilizes 'dynamic' because the compiler required type
    'System.Runtime.CompilerServices.DynamicAttribute' cannot be found.
    Are you missing a reference?
        public class _Views_Home_Index_cshtml : Microsoft.AspNetCore.Mvc.Razor.RazorPage Predefined type
    'System.Boolean' is not defined or imported
        public class _Views_Home_Index_cshtml : Microsoft.AspNetCore.Mvc.Razor.RazorPage The type 'Object' is
    defined in an assembly that is not referenced. You must add a
    reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
        public class _Views_Home_Index_cshtml : Microsoft.AspNetCore.Mvc.Razor.RazorPage The type 'Object' is
    defined in an assembly that is not referenced. You must add a
    reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            public Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
    ModelExpressionProvider { get; private set; } Predefined type
    'System.Object' is not defined or imported
            public Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
    ModelExpressionProvider { get; private set; } The type or namespace
    name 'ViewFeatures' does not exist in the namespace
    'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)
            public Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
    ModelExpressionProvider { get; private set; } Predefined type
    'System.Void' is not defined or imported
            public Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
    ModelExpressionProvider { get; private set; } The type 'Object' is
    defined in an assembly that is not referenced. You must add a
    reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            public Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; } Predefined type 'System.Object' is not defined or imported
            public Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; } The type or namespace name 'IUrlHelper' does not exist in the
    namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly
    reference?)
            public Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; } Predefined type 'System.Void' is not defined or imported
            public Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; } The type 'Object' is defined in an assembly that is not
    referenced. You must add a reference to assembly 'System.Runtime,
    Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            public Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; } Predefined type 'System.Object' is not defined
    or imported
            public Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; } The type or namespace name
    'IViewComponentHelper' does not exist in the namespace
    'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)
            public Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; } Predefined type 'System.Void' is not defined or
    imported
            public Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; } The type 'Object' is defined in an assembly that
    is not referenced. You must add a reference to assembly
    'System.Runtime, Version=4.1.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a'.
            public Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } Predefined type 'System.Object' is not defined or
    imported
            public Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } The type or namespace name 'IJsonHelper' does not
    exist in the namespace 'Microsoft.AspNetCore.Mvc.Rendering' (are you
    missing an assembly reference?)
            public Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } Predefined type 'System.Void' is not defined or
    imported
            public Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } The type 'Object' is defined in an assembly that
    is not referenced. You must add a reference to assembly
    'System.Runtime, Version=4.1.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a'.
            public Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } Predefined type 'System.Object' is not
    defined or imported
            public Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } The type or namespace name 'IHtmlHelper&lt;>'
    does not exist in the namespace 'Microsoft.AspNetCore.Mvc.Rendering'
    (are you missing an assembly reference?)
            public Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } The type 'Object' is defined in an assembly
    that is not referenced. You must add a reference to assembly
    'System.Runtime, Version=4.1.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a'.
            public Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } Predefined type 'System.Object' is not
    defined or imported
            public Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } Cannot define a class or member that
    utilizes 'dynamic' because the compiler required type
    'System.Runtime.CompilerServices.DynamicAttribute' cannot be found.
    Are you missing a reference?
            public Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } Predefined type 'System.Boolean' is not
    defined or imported
            public Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } Predefined type 'System.Void' is not
    defined or imported
            public Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } The return type of an async method must be
    void, Task or Task
            public override async Task ExecuteAsync() The type 'Object' is defined in an assembly that is not referenced. You must add a
    reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            public override async Task ExecuteAsync() Predefined type 'System.Object' is not defined or imported
            public override async Task ExecuteAsync() The type or namespace name 'Task' could not be found (are you missing a using
    directive or an assembly reference?)
            public override async Task ExecuteAsync() '_Views_Home_Index_cshtml.ExecuteAsync()': return type must be 'Task'
    to match overridden member 'RazorPage.ExecuteAsync()'
            public override async Task ExecuteAsync() The type 'Task' is defined in an assembly that is not referenced. You must add a
    reference to assembly 'System.Threading.Tasks, Version=4.0.10.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            public override async Task ExecuteAsync() Predefined type 'System.Void' is not defined or imported
            public _Views_Home_Index_cshtml()
            {
            } The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime,
    Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] Predefined type 'System.Object' is not defined or imported
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] The type 'Attribute' is defined in an assembly that is not referenced.
    You must add a reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] Predefined type 'System.Void' is not defined or imported
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] The type 'Object' is defined in an assembly that is not referenced.
    You must add a reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] Predefined type 'System.Object' is not defined or imported
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] The type 'Attribute' is defined in an assembly that is not referenced.
    You must add a reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] Predefined type 'System.Void' is not defined or imported
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] The type 'Object' is defined in an assembly that is not referenced.
    You must add a reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] Predefined type 'System.Object' is not defined or imported
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] The type 'Attribute' is defined in an assembly that is not referenced.
    You must add a reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] Predefined type 'System.Void' is not defined or imported
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] The type 'Object' is defined in an assembly that is not referenced.
    You must add a reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] Predefined type 'System.Object' is not defined or imported
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] The type 'Attribute' is defined in an assembly that is not referenced.
    You must add a reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] Predefined type 'System.Void' is not defined or imported
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] The type 'Object' is defined in an assembly that is not referenced.
    You must add a reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] Predefined type 'System.Object' is not defined or imported
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] The type 'Attribute' is defined in an assembly that is not referenced.
    You must add a reference to assembly 'System.Runtime, Version=4.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] Predefined type 'System.Void' is not defined or imported
            [Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute] Predefined type 'System.Void' is not defined or imported
            public _Views_Home_Index_cshtml() Predefined type 'System.Int32' is not defined or imported
                BeginContext(0, 181, true); Predefined type 'System.Int32' is not defined or imported
                BeginContext(0, 181, true); Predefined type 'System.Boolean' is not defined or imported
                BeginContext(0, 181, true); The type 'Object' is defined in an assembly that is not referenced. You must add a reference to
    assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a'.
                BeginContext(0, 181, true); Predefined type 'System.Object' is not defined or imported
                BeginContext(0, 181, true); Predefined type 'System.Void' is not defined or imported
                BeginContext(0, 181, true); Predefined type 'System.String' is not defined or imported
                WriteLiteral("\n\n\n    \n        \n\n        aspnetcoreapp\n<br>
    \n    \n    \n        <p>Hello, world!</p>\n<br>
    \n\n"); The type 'Object' is defined in an assembly that
    is not referenced. You must add a reference to assembly
    'System.Runtime, Version=4.1.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a'.
                WriteLiteral("\n\n\n    \n        \n\n        aspnetcoreapp\n<br>
    \n    \n    \n        <p>Hello, world!</p>\n<br>
    \n\n"); Predefined type 'System.Object' is not defined
    or imported
                WriteLiteral("\n\n\n    \n        \n\n        aspnetcoreapp\n<br>
    \n    \n    \n        <p>Hello, world!</p>\n<br>
    \n\n"); Predefined type 'System.Void' is not defined or
    imported
                WriteLiteral("\n\n\n    \n        \n\n        aspnetcoreapp\n<br>
    \n    \n    \n        <p>Hello, world!</p>\n<br>
    \n\n"); The type 'Object' is defined in an assembly that
    is not referenced. You must add a reference to assembly
    'System.Runtime, Version=4.1.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a'.
                EndContext(); Predefined type 'System.Object' is not defined or imported
                EndContext(); Predefined type 'System.Void' is not defined or imported
                EndContext(); '_Views_Home_Index_cshtml.ExecuteAsync()': not all code paths return a value
            public override async Task ExecuteAsync()</p>
  </blockquote>