title: ASP.net MVC Razor view on Mono Mac
body: <p>I created an ASP.net MVC application using Visual Studio Community Edition for Mac. When I ran the default HomeController and Index view work fine. Then I made a BookController and inside views added a folder Book and Index.cshtml file. However I keep getting the following error:</p>
  
  <blockquote>
    <p>System.InvalidOperationException The view found at
    '~/Views/book/Index.cshtml' was not created.</p>
  </blockquote>
  
  <p>Description: </p>
  
  <blockquote>
    <p>HTTP 500.Error processing request.</p>
  </blockquote>
  
  <p>Details:</p>
  
  <blockquote>
    <p>Non-web exception. Exception origin (name of application or object):
    System.Web.Mvc. Exception stack trace:   at
    System.Web.Mvc.BuildManagerCompiledView.Render
    (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer)
    [0x00061] in :0    at
    System.Web.Mvc.ViewResultBase.ExecuteResult
    (System.Web.Mvc.ControllerContext context) [0x00080] in
    :0    at
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResult
    (System.Web.Mvc.ControllerContext controllerContext,
    System.Web.Mvc.ActionResult actionResult) [0x00000] in
    :0    at
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive
    (System.Collections.Generic.IList<code>1[T] filters, System.Int32
    filterIndex, System.Web.Mvc.ResultExecutingContext preContext,
    System.Web.Mvc.ControllerContext controllerContext,
    System.Web.Mvc.ActionResult actionResult) [0x0000b] in
    &lt;cc73190bab9d435c831510ff295c572a&gt;:0    at
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive
    (System.Collections.Generic.IList</code>1[T] filters, System.Int32
    filterIndex, System.Web.Mvc.ResultExecutingContext preContext,
    System.Web.Mvc.ControllerContext controllerContext,
    System.Web.Mvc.ActionResult actionResult) [0x0009b] in
    :0    at
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters
    (System.Web.Mvc.ControllerContext controllerContext,
    System.Collections.Generic.IList<code>1[T] filters,
    System.Web.Mvc.ActionResult actionResult) [0x0000a] in
    &lt;cc73190bab9d435c831510ff295c572a&gt;:0    at
    System.Web.Mvc.Async.AsyncControllerActionInvoker+&lt;&gt;c__DisplayClass21+&lt;&gt;c__DisplayClass2b.&lt;BeginInvokeAction&gt;b__1c
    () [0x0008a] in &lt;cc73190bab9d435c831510ff295c572a&gt;:0    at
    System.Web.Mvc.Async.AsyncControllerActionInvoker+&lt;&gt;c__DisplayClass21.&lt;BeginInvokeAction&gt;b__1e
    (System.IAsyncResult asyncResult) [0x00041] in
    &lt;cc73190bab9d435c831510ff295c572a&gt;:0    at
    System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult</code>1[TResult].CallEndDelegate
    (System.IAsyncResult asyncResult) [0x00000] in
    :0    at
    System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase<code>1[TResult].End
    () [0x00029] in &lt;cc73190bab9d435c831510ff295c572a&gt;:0    at
    System.Web.Mvc.Async.AsyncResultWrapper.End[TResult]
    (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in
    &lt;cc73190bab9d435c831510ff295c572a&gt;:0    at
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction
    (System.IAsyncResult asyncResult) [0x00000] in
    &lt;cc73190bab9d435c831510ff295c572a&gt;:0    at
    System.Web.Mvc.Controller.&lt;BeginExecuteCore&gt;b__1d (System.IAsyncResult
    asyncResult, System.Web.Mvc.Controller+ExecuteCoreState innerState)
    [0x00000] in &lt;cc73190bab9d435c831510ff295c572a&gt;:0    at (wrapper
    delegate-invoke)
    System.Web.Mvc.Async.EndInvokeVoidDelegate</code>1[System.Web.Mvc.Controller+ExecuteCoreState]:invoke_void_IAsyncResult_TState
    (System.IAsyncResult,System.Web.Mvc.Controller/ExecuteCoreState)   at
    System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid<code>1[TState].CallEndDelegate
    (System.IAsyncResult asyncResult) [0x00000] in
    &lt;cc73190bab9d435c831510ff295c572a&gt;:0    at
    System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase</code>1[TResult].End
    () [0x00029] in :0    at
    System.Web.Mvc.Async.AsyncResultWrapper.End[TResult]
    (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in
    :0    at
    System.Web.Mvc.Async.AsyncResultWrapper.End (System.IAsyncResult
    asyncResult, System.Object tag) [0x00000] in
    :0    at
    System.Web.Mvc.Controller.EndExecuteCore (System.IAsyncResult
    asyncResult) [0x00000] in :0    at
    System.Web.Mvc.Controller.b__15 (System.IAsyncResult
    asyncResult, System.Web.Mvc.Controller controller) [0x00000] in
    :0    at
    System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid<code>1[TState].CallEndDelegate
    (System.IAsyncResult asyncResult) [0x00000] in
    &lt;cc73190bab9d435c831510ff295c572a&gt;:0    at
    System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase</code>1[TResult].End
    () [0x00029] in :0    at
    System.Web.Mvc.Async.AsyncResultWrapper.End[TResult]
    (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in
    :0    at
    System.Web.Mvc.Async.AsyncResultWrapper.End (System.IAsyncResult
    asyncResult, System.Object tag) [0x00000] in
    :0    at
    System.Web.Mvc.Controller.EndExecute (System.IAsyncResult asyncResult)
    [0x00000] in :0    at
    System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute
    (System.IAsyncResult asyncResult) [0x00000] in
    :0    at
    System.Web.Mvc.MvcHandler.b__5
    (System.IAsyncResult asyncResult,
    System.Web.Mvc.MvcHandler+ProcessRequestState innerState) [0x00000] in
    :0    at (wrapper delegate-invoke)
    System.Web.Mvc.Async.EndInvokeVoidDelegate<code>1[System.Web.Mvc.MvcHandler+ProcessRequestState]:invoke_void_IAsyncResult_TState
    (System.IAsyncResult,System.Web.Mvc.MvcHandler/ProcessRequestState)<br>
    at
    System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid</code>1[TState].CallEndDelegate
    (System.IAsyncResult asyncResult) [0x00000] in
    :0    at
    System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1[TResult].End
    () [0x00029] in :0    at
    System.Web.Mvc.Async.AsyncResultWrapper.End[TResult]
    (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in
    :0    at
    System.Web.Mvc.Async.AsyncResultWrapper.End (System.IAsyncResult
    asyncResult, System.Object tag) [0x00000] in
    :0    at
    System.Web.Mvc.MvcHandler.EndProcessRequest (System.IAsyncResult
    asyncResult) [0x00000] in :0    at
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest
    (System.IAsyncResult result) [0x00000] in
    :0    at
    System.Web.HttpApplication.async_handler_complete_cb
    (System.IAsyncResult ar) [0x00015] in
    /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class</p>
  </blockquote>
  
  <p>I Googled around and people said I have to make sure the web.config inside views folder is as follows:</p>
  
  <pre><code>&lt;host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
  </code></pre>
  
  <p>That is it matches the version of system.web.mvc and looking inside system.web.mvc the version is:</p>
  
  <p><strong>5.2.3</strong></p>
  
  <p>And the default view in HomeController works. I am trying out ASP.net MVC on Mac first time and never had this type of problem on Windows.</p>
  
  <p>Any help is welcome.</p>
  
  <p>Update Controller code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using TestMvcFromMac.Models;
  
  namespace TestMvcFromMac.Controllers
  {
   public class BookController : Controller
   {
  
      //Category category = new Category();
  
  
      public ActionResult Index()
      {
          return View ();
      }
  
  
   }
  }
  </code></pre>