加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – ASP.NET MVC Intellisense没有找到ViewData

发布时间:2020-12-15 19:54:04 所属栏目:asp.Net 来源:网络整理
导读:我试图在asp.net上浏览 following tutorial.当我开始使用这段代码时: %@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="MvcApplication1.Views.Home.Index" % %@ Import N
我试图在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.

解决方法

尝试在MVC项目上进行构建.在第一次编译后面的代码之前,intellisense将不起作用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读