@Html.Action errors in Views

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 năm cách đây
Hello,

Many of the views show errors in Visual Studio :


Error  6  'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'Action' and no extension method 'Action' accepting a first argument of type 'System.Web.WebPages.Html.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)  Views\Catalog\CategoryTemplate.ProductsInGridOrLines.cshtml  

I Googled this and came up with:
http://stackoverflow.com/questions/4449909/why-cant-razor-find-my-html-helper

But the pageBaseType in Nop.Web derives from Nop.Web.Framework....

Any ideas, as this is annoying, project works but getting erros in Views is distracting...

Thanks !
(Using VS2012)
11 năm cách đây
in Nop.Web.Framework there is a file called HtmlExtension.cs.
that contains html extension methods.
so add the namespace Nop.Web.Framework to that file.
11 năm cách đây
Hello,

Thanks, but it's already there...


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.WebPages;
using Nop.Core;
using Nop.Core.Infrastructure;
using Nop.Services.Localization;
using Nop.Web.Framework.Localization;
using Nop.Web.Framework.Mvc;
using Nop.Web.Framework;
using Telerik.Web.Mvc.UI;

namespace Nop.Web.Framework
{
    public static class HtmlExtensions
    {
        public static MvcHtmlString ResolveUrl(this HtmlHelper htmlHelper, string url)
        {
            var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext);
            return MvcHtmlString.Create(urlHelper.Content(url));
        }

        public static MvcHtmlString Hint(this HtmlHelper helper, string value)
        {
...

...

11 năm cách đây
Ah, you mean to the view...

Added and rebuild and still:


@using Nop.Web;
@using Nop.Web.Framework;
@using Nop.Web.Framework.UI;
@using Nop.Web.Models.Catalog;
@using Nop.Web.Models.Company;
@using Nop.Web.Extensions;
@using Nop.Web.Framework.Extensions;
@using Nop.Web.Framework.ViewEngines.Razor;

<div class="category-page">

    @Html.Action("WidgetsByZone", "Widget", new { widgetZone = "categorydetails_top" })



@Html.Action -> error on Action
11 năm cách đây
Hi,

i'm having the same problem :(
Did you found the cause of the problem?

Thanks
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.