0

The topic error shows when I add the method in common controller and call that method from Header view file which is located under the Theme => View => Shared in nopcommerce 3.80.

Here is my method which I call from common controller

public ActionResult MobileBrowser()
{
    var browser = Request.Browser;
    System.Web.HttpBrowserCapabilitiesBase myBrowserCaps = browser;
    if (((System.Web.HttpBrowserCapabilitiesBase)myBrowserCaps).IsMobileDevice)
    {
        ViewBag.Message = "mob";
    }
    else
    {
        ViewBag.Message = "web";
    }
    return View();
}

Here is the View file of MobileBrowser method

@if (ViewBag.Message == "mob")
{
    Mobile
}

@if (ViewBag.Message == "web")
{
    Web
}

Here is the Header.cshtml from where I calling MobileBrowser method from common controller

@Html.Action("MobileBrowser", "Common")
karan
  • 482
  • 1
  • 8
  • 30
  • 1
    `InsufficientExecutionStackException` often indicates that the recursive action was executed, especially if you put `@Html.Action` or `@Html.RenderAction` in a certain view which pointing to same action name which returns the view page. I guess that `@Html.Action` helper is the culprit, try using different action name. – Tetsuya Yamamoto Mar 18 '19 at 07:43
  • can you suggest me different action name – karan Mar 18 '19 at 07:50
  • The execution flow seem starts from calling controller action => return view => view has `@Html.Action` to same action => return same view again and the cycle will repeat indefinitely until `StackOverflowException` reached. Since you're using header view, could you try return partial view instead? – Tetsuya Yamamoto Mar 18 '19 at 07:59

1 Answers1

0

I got the solution, I code the partialview in the replace of view. Special Thankx to Tetsuya Yamamoto for the suggestion.

karan
  • 482
  • 1
  • 8
  • 30