问题:
System.InvalidOperationException
The view '~/Views/Mobile/ProfilesGridView.cshtml' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Mobile/ProfilesGridView.cshtml
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.Mvc.
Exception stack trace:
at System.Web.Mvc.ViewResult.FindView (System.Web.Mvc.ControllerContext context) [0x00083] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) [0x0003b] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (System.Collections.Generic.IList`1[T] filters, System.Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0000b] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (System.Collections.Generic.IList`1[T] filters, System.Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0009b] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (System.Collections.Generic.IList`1[T] filters, System.Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0009b] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters (System.Web.Mvc.ControllerContext controllerContext, System.Collections.Generic.IList`1[T] filters, System.Web.Mvc.ActionResult actionResult) [0x0000a] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass3_6.<BeginInvokeAction>b__4 () [0x000f8] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass3_1.<BeginInvokeAction>b__1 (System.IAsyncResult asyncResult) [0x00041] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1[TResult].CallEndDelegate (System.IAsyncResult asyncResult) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1[TResult].End () [0x00029] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult] (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction (System.IAsyncResult asyncResult) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Controller+<>c.<BeginExecuteCore>b__152_1 (System.IAsyncResult asyncResult, System.Web.Mvc.Controller+ExecuteCoreState innerState) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid`1[TState].CallEndDelegate (System.IAsyncResult asyncResult) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1[TResult].End () [0x00029] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult] (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End (System.IAsyncResult asyncResult, System.Object tag) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Controller.EndExecuteCore (System.IAsyncResult asyncResult) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Controller+<>c.<BeginExecute>b__151_2 (System.IAsyncResult asyncResult, System.Web.Mvc.Controller controller) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid`1[TState].CallEndDelegate (System.IAsyncResult asyncResult) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1[TResult].End () [0x00029] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult] (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End (System.IAsyncResult asyncResult, System.Object tag) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Controller.EndExecute (System.IAsyncResult asyncResult) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute (System.IAsyncResult asyncResult) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.MvcHandler+<>c.<BeginProcessRequest>b__20_1 (System.IAsyncResult asyncResult, System.Web.Mvc.MvcHandler+ProcessRequestState innerState) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid`1[TState].CallEndDelegate (System.IAsyncResult asyncResult) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1[TResult].End () [0x00029] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult] (System.IAsyncResult asyncResult, System.Object tag) [0x00007] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.Async.AsyncResultWrapper.End (System.IAsyncResult asyncResult, System.Object tag) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.MvcHandler.EndProcessRequest (System.IAsyncResult asyncResult) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest (System.IAsyncResult result) [0x00000] in <c11f3b1e27ba4255a48f3fa4d01496ab>:0
at System.Web.HttpApplication.async_handler_complete_cb (System.IAsyncResult ar) [0x00015] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/System.Web/System.Web/HttpApplication.cs:988
到目前为止我尝试过的:
这个 asp.net MVC 项目在 Windows 上运行良好。在 Mac 上,我将软件包更新到最新版本:
<package id="Microsoft.AspNet.Mvc" version="5.2.9" targetFramework="net472" />
<package id="Microsoft.AspNet.Razor" version="3.2.9" targetFramework="net472" />
然后在
Views/web.config
中,将MvcWebRazorHostFactory
更新到最新版本,即
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
进行此更改后,一些视图开始工作,仅返回视图。e,g:
public ActionResult ForgetPassword()
{
return View();//working
}
但不起作用:
return View("~/Views/Mobile/ProfilesGridView.cshtml", viewModel);//not working
该视图存在于位置
/Views/Mobile/ProfilesGridView.cshtml
并且正在 Windows 上运行。
假设只有.NET Core(或.NET 5.0以上)版本可以在macOS上运行,那么您的.NET版本是多少?