1

我目前在asp.net c#中创建一个网站,使用带有数据库的windows azure,当我将文件推送到服务器时它工作得很好,奇怪的是每次我点击播放按钮时都会出现这个错误。它已经到了必须继续将其发送到服务器进行预览变得烦人的地步,如果有人可以帮助我解决这个问题,将不胜感激。我还阅读了有关“区域注册”的信息,并尝试了很多方法,但似乎都没有奏效。这是我的 RouteConfig.cs

   public class RouteConfig
    {
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(
name: "View",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional}
        ); 
      } 
    }

当我编辑网址时:

   "{controller}/{action}/{id}"

并输入网址:

  "Views/Home/{action}/{id}" 

目录刚刚加载,允许我手动选择文件,错误 dosnt 出现,但索引无法访问,当我单击 Views 时,它变为“localhost - /Views/”但页面保持不变,我单击“视图”,我得到一个 404“请求的 URL:/Views/Views/”

这是我收到的错误:

 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) +355958
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +121
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext    
controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter,    
ResultExecutingContext preContext, Func`1 continuation) +242
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext    
controllerContext, IList`1 filters, ActionResult actionResult) +177
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +89
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult  
asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult  
asyncResult) +43
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult)  
+14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult 
asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) 
+25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult 
result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()  
+9629296
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&  
completedSynchronously) +155

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET   
Version:4.0.30319.18034
4

2 回答 2

1

To simply add view:

Right mouse button inside HomeController Index action and choose "add View".

于 2013-06-25T20:41:33.367 回答
0

从外观上看,您缺少 index.cshtml 文件。

在您的项目中,您可以有一个与控制器文件夹处于同一级别的视图文件夹。其中应该有一个与控制器同名的文件夹减去“控制器”文本。 Index.cshtml 需要存在于其中。

于 2013-05-31T15:26:08.797 回答