当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net mvc 5 - PartialView is not found

问题描述:

The controller is in /Areas/ShoppingCart/Controllers/

I've tried to let the controller return the PartialView which in /Views/Shared folder.

The Code as follows:

namespace MVCIIITourism.Areas.shoppingcart.Controllers

{

public class CartController : Controller

{

public ActionResult GetCart()

{

return PartialView("../../Shared/Views_Cartpatail.cshtml");

}

public ActionResult AddToCart(int id)

{

var currentCart = Operation.GetCurrentCart();

currentCart.AddProduct(id);

return PartialView("../../Shared/Views_Cartpatail.cshtml");

}

}

}

But the chrome shows the error message that is

Not Found PartialView in /Areas/ShoppingCart/Controllers/

How should I fix the problem?

网友答案:

If your partial is in the shared folder you don`t have to pass the entire path

Shared folder it`s access by all controllers

Simple use:

return PartialView("Views_Cartpatail.cshtml");
分享给朋友:
您可能感兴趣的文章:
随机阅读: