2017-06-19 20 views
0

我正在为我的学校的一个新项目,我试图发布我的网站在ASP.Net MVC IIS 8在Windows Server 2012 R2上。'/'应用程序中的服务器错误。与视图

我的项目与Framework .net 4.5.2。

当我尝试启动我的IIS网站,我有这样的错误:

Server Error in '/' Application. 

    The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched: 
    ~/Views/Home/Index.aspx 
    ~/Views/Home/Index.ascx 
    ~/Views/Shared/Index.aspx 
    ~/Views/Shared/Index.ascx 
    ~/Views/Home/Index.cshtml 
    ~/Views/Home/Index.vbhtml 
    ~/Views/Shared/Index.cshtml 
    ~/Views/Shared/Index.vbhtml 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched: 
    ~/Views/Home/Index.aspx 
    ~/Views/Home/Index.ascx 
    ~/Views/Shared/Index.aspx 
    ~/Views/Shared/Index.ascx 
    ~/Views/Home/Index.cshtml 
    ~/Views/Home/Index.vbhtml 
    ~/Views/Shared/Index.cshtml 
    ~/Views/Shared/Index.vbhtml 

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

而且我有这个太:

Stack Trace: 


    [InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched: 
    ~/Views/Home/Index.aspx 
    ~/Views/Home/Index.ascx 
    ~/Views/Shared/Index.aspx 
    ~/Views/Shared/Index.ascx 
    ~/Views/Home/Index.cshtml 
    ~/Views/Home/Index.vbhtml 
    ~/Views/Shared/Index.cshtml 
    ~/Views/Shared/Index.vbhtml] 

    System.Web.Mvc.ViewResult.FindView(ControllerContext context) +499 
    System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +143 

    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +88 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +831 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81 
    System.Web.Mvc.Async.<>c__DisplayClass21. 
    <BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185 
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38 
    System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +67 
    System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36 
    System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38 
    System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +43 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +67 
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +607 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +134 

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2053.0 

我试着用.NET框架V4.5一切4.5.2或为我的项目和我的应用程序池:

.NET v2.0 (version v2.0 and v4.0.39319 of CLR.NET) 
    .NET v2.0 Classic (version v2.0.50727 of CLR.NET and v4.0.39319 of CLR.NET) 
    .NET v4.5 (version v4.0.39319 of CLR.NET and v2.0.50727 of CLR.NET) 
    .NET v4.5 Classic v4.0.39319 of CLR.NET and v2.0.50727 of CLR.NET) 
    Classic .NET AppPool (version v4.0.39319 of CLR.NET and v2.0.50727 of CLR.NET) 
    DefaultAppPool (version v4.0.39319 of CLR.NET and v2.0.50727 of CLR.NET) 

UPDATE: 首先,感谢您的回答。

我正在使用MVC,我已经创建了控制器,并使用该控制器默认使用视图创建。我没有改变他们的名字或任何东西。只需在其中添加一些代码即可。我的项目以及与Visual Studio 2015年社区

对于剩下的工作,我的浏览文件夹是这样的:

--> Views 
    --> Home 
     --> About.cshtml 
     --> Contact.cshtml 
     --> Legal.cshtml (not used) 
    --> Participants 
     --> Create.cshtml 
     --> Index.cshtml 
    --> Shared 
     --> _Layout.cshtml 
     --> Error.cshtml 

一件事是,我已经把我的文件夹“的Inetpub - > wwwroot文件 - > MyFolder。我已经添加了IUSR和IIS_IUSRS的权限来读取和执行。我已经尝试将权限改为完全控制。

这不是我在ASP.NET MVC中添加到IIS中的第一个项目,但对于这一个我不知道什么是问题...

我希望y OU可以帮助我,因为我有一周结束前发布这个网站...

由于提前,

Mattexis

+0

你确定有一个文件夹'Views/Home/Index。***'?它确实发布了吗?你的文件夹结构是什么样的 – Jonesopolis

+4

当某事说“我在这里找不到文件”时,你需要去验证1)该文件实际上是否存在,以及2)试图访问该文件的帐户有权读取(并且可能执行)它。 – Will

+0

我已经把更多的信息放在页面中,但是,我有这个文件夹和这个文件。谢谢 – Mattexis

回答

0

这其实答案不应该是值得的#1 ..但我猜你并没有真正意识到什么是mvc,以及它是如何工作的,因为你需要检查这个link

反正这个问题。我相信你已经添加了动作控制器内象下面这样:

public ActionResult Index() 
{ 
    return View(); 
} 

您可以右键单击Index和创建视图,在创建对话框中,它要求你命名视图,如果你已经改变了它的名字那么你需要返回视图名称,如:

public ActionResult Index() 
{ 
    return View("Changed"); 
} 

虽然它的名称相同的动作你轻松只是return View();

现在,如果你不知道你是否已经改变与否,这里是如何你可以检查一下:

当您创建控制器时,它还会在视图文件夹中创建一个与您的控制器具有相同名称的文件夹。所以如果创建HomeController,它还会在您的View文件夹中创建Home文件夹。打开这个文件夹检查文件的名称是什么,或者是否有文件?

请务必记住这一点,如果您从控制器中的某个操作调用视图,该视图需要与您的控制器位于同一文件夹中或共享文件夹中,否则您会收到上述错误。

更新:

也为@Will提到的,如果你正在运行需要验证尝试访问该文件的帐户有权读取服务器上的应用程序。

相关问题