I have a route define for controller using attribute routing
[RoutePrefix("blog")]
public class BlogController : Controller
{
[HttpGet]
[Route("detail")]
public ActionResult Detail()
{
return Content("hello");
}
}
I have a child only action that is being render in _Layout.cshtml
public class NotificationController : Controller
{
[ChildActionOnly]
public ActionResult Index()
{
return PartialView("_Notification");
}
}
inside _Layout.cshtml
@{
try
{
Html.RenderAction("Index", "Notification");
}
catch (Exception e)
{
//never hit in case of exception, not sure why
}
}
when I do a GET
request on /blog/detail
, everything works but when I do a POST
request on /blog/detail
, it throws stackoverflow exception
inside _Layout.cshtml
where it is trying to render partial view
.
Further more, if I remove [Route("detail")]
from Detail action, and then do a POST
request on /blog/detail
, the server reject a call and return 404
in response
. That is what I'm expecting by keeping the Route
attribute but not sure why it behaves differently.