简体   繁体   English

“ /”应用程序中的服务器错误。 与视图

[英]Server Error in '/' Application. with View

I'm working on a new project for my school, and I'm trying to publish my website in ASP.Net MVC in IIS 8 on a Windows Server 2012 r2. 我正在为我的学校开展一个新项目,并且试图在Windows Server 2012 r2上的IIS 8中的ASP.Net MVC中发布我的网站。

My project is with Framework .net 4.5.2. 我的项目是使用Framework .net 4.5.2。

When I try to launch my website on IIS I have this error : 当我尝试在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. 

And I have this too : 我也有这个:

    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 

I've tried everything with framework .net v4.5 or 4.5.2 for my project and for my application pool : 我已经为我的项目和应用程序池使用了框架.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 : First of all, thanks for your answers. 更新:首先,感谢您的回答。

I'm using MVC and I have create controllers and used the view create by default with this controller. 我正在使用MVC,并且具有创建控制器,并且默认情况下将此视图与该控制器一起使用。 I haven't change their name or anything. 我没有改变他们的名字或其他任何东西。 Just put some code in it. 只需在其中添加一些代码即可。 My project work well with Visual Studio Community 2015. 我的项目与Visual Studio Community 2015配合良好。

For the rest, my Views folder is like this : 其余的,我的Views文件夹是这样的:

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

One more thing is that I've put my folder in "inetpub --> wwwroot --> MyFolder . And I have added rights for IUSR and IIS_IUSRS to read and execute. I've already tried to change right to total control. 还有一件事是,我已经将文件夹放在“ inetpub-> wwwroot-> MyFolder中。我还为IUSR和IIS_IUSRS添加了读取和执行的权限。我已经尝试过更改完全控制权。

It's not the first project I add to IIS in ASP.NET MVC, but for this one I don't know what is the problem... 这不是我在ASP.NET MVC中添加到IIS的第一个项目,但是对于这个项目,我不知道是什么问题...

I hope you can help me because I have to publish this website before the end of the week... 希望您能对我有所帮助,因为我必须在本周末之前发布此网站...

Thanks in advance, 提前致谢,

Mattexis Mattexis

This answer is actually shouldn't be worthy of Stackoverflow.. but i am guessing you didn't really realized what is mvc and how its working for that you need to check this link . 这个答案实际上不应该是Stackoverflow值得的。但是我猜您没有真正意识到mvc是什么,以及它如何工作,您需要检查此链接

Anyways as for this issue. 无论如何,关于这个问题。 i believe you have added an action within your controller like below: 我相信您已经在控制器中添加了一个动作,如下所示:

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

You can right click on the Index and Create a View, In the Create dialog it asks you to name the View, if you have changed it's name then you need to return the View name like: 您可以右键单击“ Index并创建一个视图,在“创建”对话框中,它要求您命名视图,如果更改了它的名称,则需要返回如下视图名称:

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

While its the same name as the action you easily just return View(); 尽管其名称与动作相同,但您只需return View();

Now if you do not know if you have changed it or not, here is how you can check this out: 现在,如果您不知道是否进行了更改,可以通过以下方法进行检查:

When you create a controller it also create a folder with same name as your controller within the view folder. 创建控制器时,它还会在视图文件夹中创建一个与控制器名称相同的文件夹。 so if create HomeController, it also creates the Home Folder within your View Folder. 因此,如果创建HomeController,它也会在您的View文件夹中创建Home文件夹。 Open this Folder check what is the name of the file or is there a file there even? 打开此文件夹,检查文件的名称是什么,甚至还有文件?

Always remember this if you are calling a view from an action in a controller, the view needs to be in same folder as your controller or in the shared folder, otherwise you receive the error above. 如果要从控制器中的操作调用视图,请务必记住这一点,该视图必须与控制器位于同一文件夹中或位于共享文件夹中,否则您会收到上述错误。

Update: 更新:

also as @Will mentioned, if you are running the application on the server you need to verify the account attempting to access the file has rights to read. 就像@Will提到的那样,如果您正在服务器上运行该应用程序,则需要验证尝试访问该文件的帐户是否具有读取权限。

You have deployed your MVC files to a virtual directory. 您已将MVC文件部署到虚拟目录。 Open IIS admin and convert the directory to an application . 打开IIS admin 并将目录转换为应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 应用程序中的异常服务器错误。 编译错误 - Unhandel Server Error in Application. Compilation Error “ /”应用程序中的服务器错误。 在c#.net - Server Error in '/' Application. in c#.net “ /”应用程序中的服务器错误。 未安装打印机 - Server Error in '/' Application. No printers are installed “ /”应用程序中的服务器错误。 尚无此类主机 - `Server Error in '/' Application. No such host is known ASP.NET:配置错误(“ /”应用程序中的服务器错误。) - ASP.NET : Configuration Error(Server Error in '/' Application.) (“/”应用程序中的服务器错误。找不到文件)Windows Azure 中的错误 - (Server Error in '/' Application. Could not find file )error in Windows Azure “ /”应用程序中的服务器错误。 未指定的错误[5,sqlcese40.dll] - Server Error in '/' Application. Unspecified error [ 5,sqlcese40.dll ] 该错误是什么意思““ /”应用程序中的服务器错误。 - what does the error mean“Server Error in '/' Application.” 收到错误“‘/’应用程序中的服务器错误。” 当我运行程序时 - Getting error "Server Error in '/' Application." when I run the program Postman 预览“/”应用程序中的服务器错误。 没有找到您要查的资源' - Postman preview 'Server Error in '/' Application. The resource cannot be found'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM