0

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.

Ammar Khan
  • 346
  • 1
  • 9
  • 27
  • where is your httppost code?? where is the post method code – RAHUL S R Mar 29 '18 at 13:04
  • I don't have `httpost` code for `/blog/detail` but in real application where the `PCI` scan run, somehow it make a post request on `/blog/detail` that is where it is crashing the site due to `stackoverflow` exception. So it should return 404 when someone make a `post` request on `/blog/detail` like it does when I remove the `[Route]` attribute. – Ammar Khan Mar 29 '18 at 13:10

0 Answers0