Area in MVC3- RedirectToAction is not working as expected
-
25-10-2019 - |
Question
I have an area called coverage.The routing is like
context.MapRoute(
"CoverageSummary", // Route name
"Coverage/Summary/{policyId}", // URL with parameters
new { controller = "Coverage", action = "Summary", policyId = UrlParameter.Optional }, // Parameter defaults
new string[] { "Web.Mvc.Claims.Areas.Coverage.Controllers" }
);
when I acess the page Mysite/Coverage/Summary/10 it shows a page. fine. But in an Action methode i have code as below
return RedirectToAction("Summary","Coverage", new RouteValueDictionary(new { policyID = 10 }));
but this is not loading the page Mysite/Coverage/Summary/10 . it is showing 404 error. if i refresh the page still it give 404.but if i cut and past the same url in address bar and hit enter it works
What can be the reason
Solution
Try with area property in your RouteValueDicitionary
return RedirectToAction("Summary","Coverage", new RouteValueDictionary(new { policyID = 10, area = "Your_Area_Name" }));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow