MVC 5.0中找不到方法错误

时间:2016-12-06 14:42:58

标签: c# .net asp.net-mvc-5

我是asp.net mvc的新手,已经开始使用5.0版本了。

这是我的controller

 public class DimCustomersController : Controller
    {
        private Sales_DW db = new Sales_DW();

        // GET: DimCustomers
        public ActionResult Index()
        {
            return View(db.DimCustomers.ToList());
        }
}

这是我的Index观点:

@model IEnumerable<WebAppDisplay.Models.DimCustomer>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.CustomerAltID)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.CustomerName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Gender)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.CustomerAltID)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CustomerName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Gender)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.CustomerID }) |
            @Html.ActionLink("Details", "Details", new { id=item.CustomerID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.CustomerID })
        </td>
    </tr>
}

</table>

我尝试运行此Index方法,但收到错误:

  

找不到方法:'System.Web.Routing.RouteValueDictionary   System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object的)”

尝试使用Mvc 5.1 MissingMethodException System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached和其他类似链接解决我的查询,但所有努力都徒劳无功。

堆栈跟踪如下:

  

[MissingMethodException:找不到方法:   “System.Web.Routing.RouteValueDictionary   System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object的)”。]   System.Web.Mvc.RouteCollectionExtensions.CreateRouteValueDictionaryUncached(对象   值)+0
  System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection   routes,String url,Object constraints)+94
  System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection   routes,String url)+7
  WebAppDisplay.RouteConfig.RegisterRoutes(RouteCollection路由)中   c:\ Users \ cc-aakashthakur \ Documents \ Visual Studio   2015年\项目\ WebAppDisplay \ WebAppDisplay \ App_Start \ RouteConfig.cs:14   WebAppDisplay.MvcApplication.Application_Start()in   c:\ Users \ cc-aakashthakur \ Documents \ Visual Studio   2015 \项目\ WebAppDisplay \ WebAppDisplay \ Global.asax.cs中:17

     

[HttpException(0x80004005):找不到方法:   “System.Web.Routing.RouteValueDictionary   System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object的)”。]   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext的   上下文,HttpApplication app)+9964625
  System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr的   appContext,HttpContext上下文,MethodInfo []处理程序)+118
  System.Web.HttpApplication.InitSpecial(HttpApplicationState状态,   MethodInfo [] handlers,IntPtr appContext,HttpContext context)+172
  System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr的   appContext,HttpContext context)+339
  System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr的   appContext)+296

     

[HttpException(0x80004005):找不到方法:   “System.Web.Routing.RouteValueDictionary   System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object的)”。]   System.Web.HttpRuntime.FirstRequestInit(HttpContext context)+9946132   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)+90   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest   wr,HttpContext context)+261

有人可以帮忙吗。

0 个答案:

没有答案