I just finished going through this checklist to upgrade my asp.net mvc2 site to mvc3: http://www.asp.net/learn/whitepapers/mvc3-release-notes#upgrading
Everything is compiling, but when I run the application I get errors in the views.
Example View:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/site.Master" Inherits="System.Web.Mvc.ViewPage<Genesis.Domain.Entities.StreamEntry>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
<%: Model.seTitle %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MetaContent" runat="server">
<%: Html.GetMetaTag("description", Model.seDescription )%>
<%: Html.GetMetaTag("keywords", Model.seKeywo开发者_如何学运维rds )%>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="HeadlineContent" runat="server">
<%: Model.seHeadline %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<p>
<%//: Html.AddThis() %>
</p>
<p>
Created: <br /><strong><%: Model.seDateCreated %></strong><br />
Last Modified: <br /><strong><%: Model.seDateModified %></strong>
</p>
<%: MvcHtmlString.Create(Model.seBody) %>
<% Html.RenderAction("Comments", "Comments", new { streamEntryID = Model.seID, allowComments = Model.AllowComments }); %>
</asp:Content>
Error text:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper<Genesis.Domain.Entities.StreamEntry>' does not contain a definition for 'GetMetaTag' and no extension method 'GetMetaTag' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<Genesis.Domain.Entities.StreamEntry>' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 6:
Line 7: <asp:Content ID="Content3" ContentPlaceHolderID="MetaContent" runat="server">
Line 8: <%: Html.GetMetaTag("description", Model.seDescription )%>
Line 9: <%: Html.GetMetaTag("keywords", Model.seKeywords )%>
Line 10: </asp:Content>
How do I get my views to recognize my custom html helpers again?
Try adding an Import
directive on the top of the view to see if it makes any difference:
<%@ Import Namespace="Namespace.Of.The.Class.Containing.The.Helper" %>
Also you could add this namespace to the <namespaces>
section of web.config.
精彩评论