ASP.NET Mvc convert <%@ Import Namespace="Thirpartynamespace" %> to Razor View
I'm trying to convert the mvc 3 aspx view engine to razor view engine b开发者_开发问答elow:
<%@ Import Namespace="ThirdpartyComp.Web.UI" %>
<% = Html.SomeFunction("Test")%>
to:
@using ThirdpartyComp.Web.UI
@Html.SomeFunction("Test")
When I do @html.SomeFunction(... I get this exeption:
Are you missing a using directive or an assembly reference?
Could anyone please confirm if above is possible, and anything that I'm missing?
Thank you heaps.
The two code snippets are precisely equivalent. The problem lies somewhere else. Ensure that you have referenced the assembly containing this helper to the new project (Add Reference... in the project) and that this assembly is compatible with ASP.NET MVC 3 i.e. it depends on the System.Web.Mvc V3 instead of V2. If this is not the case you might need to recompile it against ASP.NET MVC 3 (if you have the source code) or ask the author for a version which is compatible with it.
精彩评论