ASP.NET MVC Intellisense没有找到ViewData

时间:2009-01-25 03:04:35

标签: asp.net-mvc

我正在尝试浏览asp.net上的following tutorial。当我开始使用这段代码时:

    <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="MvcApplication1.Views.Home.Index" %> 
<%@ Import Namespace="MvcApplication1.Models" %> 
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"> 
<table> 
<tr>      
<th>Id</th>
<th>Title</th>
<th>Release Date</th> 
</tr> 
<% foreach (Movie m in (IEnumerable)ViewData.Model) { %> 
<tr>      
      <td><%= m.Id %></td>
      <td><%= Html.Encode(m.Title) %></td>
      <td><%= m.DateReleased %></td>
 </tr>
 <% } %>
 </table>
 </asp:Content> 

当我输入ViewData时,它不会在intellisense中显示,就好像我没有包含引用或其他内容。另外下来Html.Encode Html没有在intellisense中显示。我做错了什么?

我使用的是最新版本的MVC。

2 个答案:

答案 0 :(得分:4)

尝试在MVC项目上进行构建。直到第一次编译后面的代码才会有效。

答案 1 :(得分:0)

我发现强制执行此操作的最佳方法是保存文件,构建关闭文件并重新打开它... 95%的时间适用于我。这是一个已知问题,已在ASP.NET MVC的RC中修复。

相关问题