如何将数据发送到操作并返回具有viewmodel对象的不同视图。如何传递json字符串的锚点标记mvc 5
我想从index.cshtml页面发送json字符串到动作,并且想要重定向或返回到具有viewmodel对象的Tax.cshtml页面。 剃刀:
<li class="mt5"><a id="noOfCart" href="@Url.Action("ReviewOrder", "Tax",new {storedTaxyear=localStorage.getItem("taxyear")})"><i class="fa fa-shopping-cart fa-lg hover1 textwhite"></i><span class="shoppingbadge"></span></a></li>
控制器
public ActionResult ReviewOrder(string storedTaxyear)
{
ViewBag.FormName = 1;
ServicesCategoryList objviewmodel = new ServicesCategoryList();
return View("Tax", objviewmodel);
}
是表示不存在的localStorage
您无法将JavaScript变量传递给Razor变量。尝试将localStorage.getItem(“taxyear”)放在隐藏字段中,然后将其值传递给 – Kostis