Last post Sep 30, 2019 11:25 AM by PatriceSc
Sep 29, 2019 10:30 PM|bkarakaya01|LINK
I tried to create custom error pages and view them while my environment is still "Development", so in my Startup.cs file I change my code into :
Then I create an Error Action in my HomeController.cs and a PageNotFound action. So my HomeController.cs now looks like :
public IActionResult Error(int? code = null)
if(code.Value == 404)
public IActionResult PageNotFound()
Actually this works great except this redirects too much. For example, If I would like to go to a page which will return status code of 404, then what happens in my debug is, Error action calls 5~ times and then suddenly it returns my View("PageNotFound).
And this is not the only issue, main issue is, after every action call(No matter if it returns an Error or not) my debugger goes to Error Action, repeats this 5 times
then suddenly returns the main page content... What is happening here, what am I missing? Someone please help me.. Thank you!
Sep 30, 2019 12:38 AM|oned_gk|LINK
AFAIK, the error message indicate that code causing redirection loop
Sep 30, 2019 09:17 AM|Rena Ni|LINK
I could not reproduce your issue by using your code.I could get into the Error action for only one time when I use the wrong url.
Could you share more details about your Startup.cs or a demo that could reproduce your issue?And you need to check whether there are any other errors or not in your project which results in it would repeat to go to Error Action.
This way also works well:
Sep 30, 2019 11:25 AM|PatriceSc|LINK
What if you drop UseExceptionHandler? Also I woluld use F12 Network (and "preserve log") to better understand which redirections are happening.