主题错误显示我在中添加方法> common Controller 并从 header View 位于 them => view =>共享下的文件> nopCommerce 3.80 。
这是我从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();
}
这是 Mobilebrowser的视图文件方法
@if (ViewBag.Message == "mob")
{
Mobile
}
@if (ViewBag.Message == "web")
{
Web
}
这是 header.cshtml 我从 common> common controller
from ther@Html.Action("MobileBrowser", "Common")
我得到了解决方案,我在 view 的替换中代码 partialView 。特别感谢 Tetsuya Yamamoto 建议。