asp.net mvc - Why did my custom HtmlHelpers stop working after I upgraded to MVC3? -


i finished going through checklist upgrade asp.net mvc2 site mvc3: http://www.asp.net/learn/whitepapers/mvc3-release-notes#upgrading

everything compiling, when run application errors in 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.sekeywords )%> </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: error occurred during compilation of resource required service request. please review following specific error details , modify source code appropriately.   compiler error message: cs1061: 'system.web.mvc.htmlhelper<genesis.domain.entities.streamentry>' not contain definition 'getmetatag' , no extension method 'getmetatag' accepting first argument of type 'system.web.mvc.htmlhelper<genesis.domain.entities.streamentry>' found (are missing using directive or 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 views recognize custom html helpers again?

try adding import directive on top of view see if makes difference:

<%@ import namespace="namespace.of.the.class.containing.the.helper" %> 

also add namespace <namespaces> section of web.config.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -