Search code examples
asp.net-mvc-3-areas

Area in MVC3- RedirectToAction is not working as expected


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" }));