2011-11-29 145 views
0

在视图/跳转/索引有问题。看不到控制器和型号

第一行:

@model IEnumerable<WhislaMvc.Areas.Admin.Models.Jump> 
@{ 
    ViewBag.Title = "Index"; 
} 

@model和ViewBaf - 看不到。 我把错误:

compilation Error Compiler Error Message: CS0103: The name 'model' does not exist in the current context Compiler Error Message: CS0103: The name 'ViewBug' does not exist in the current context

enter image description here

更新: 我评论模型和ViewBag

@Html.ActionLink("Create New", "Create") 

的Html没有办法的ActionLink为什么????

回答

0

从你的问题的描述,它表明,我认为你正在使用Asp.Net MVC 2,你只是试图用functionality of Asp.Net MVC 3.

ViewBag自带Asp.Net MVC 3 (It's feature of Asp.Mvc 3)

有一些建议,你可以尝试避免编译错误。

  1. 安装Asp.Net MVC 3(安装Net Framework 4 prior

  2. Change your project property.(右键单击Web项目 - >点击 '属性' - >应用程序选项卡 - >目标框架 - >更改为 .NET框架4

检查和更改你的web.config如下:

<compilation debug="true" targetFramework="4.0"> 
      <assemblies> 
       <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
       <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
       <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
       <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
       <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
       <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
      </assemblies> 
     </compilation> 

希望这有助于!

0

所有的问题都与web.config文件中区/管理/查看配置

WebConfig我从查看/ Web.Config中获得/是非标准。

+0

这应该是一个评论,而不是和“答案”。 – DaveShaw

+1

@DaveShaw - 公平地说,这是OP回答他自己的问题。丹尼斯卡 - 如果你能扩大你的答案,并且记得在能够时标记为已接受,那将是有用的。 – Kev