ASP.NET MVC View not rendering with layout after form post using angular
I am routing views using ngRoute and have no specific issues showing most views. The only problem I am facing is when I do a post method and pass the list to the view.
The site / page displays a view without layout. Typing in the address bar http: // localhost: 7351 / Page works and provides the layout, but obviously no view. If I submit the form to http: // localhost: 7351 / Main , the browser url changes to http: // localhost: 7351 / Site / Page and displays the results without any layout.
Form in sight Home
<form method="post" action="Site/Page">
<input id="chk_main" type="checkbox" />
<input type=submit>
</form>
RouteConfig
routes.MapRoute(
name: "Page",
url: "Site/Page",
defaults: new { controller = "Site", action = "Page" }
);
EDIT: If I change "url: Site / Page" to "url: Page" then Layout will show, but then View won't.
controller
public ActionResult Index()
{
return View();
}
public ActionResult Main()
{
return View(persons);
}
[HttpPost]
public ActionResult Page()
{
return View();
}
Angular Route Provider:
$routeProvider.
when('/Main', {
templateUrl: 'Site/Main'
})
.when('/contact', {
templateUrl: 'Site/Contact'
})
.when('/Page', {
templateUrl: 'Site/Page'
})
Is there something I don't see or understand.
source to share
No one has answered this question yet
Check out similar questions: