Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I'm routing the views using ngRoute and not having any particular issues rendering most views. The only problem I am having is when I do a post method and passing a list to the view.

Site/Page renders the view with no layout. Typing into the address bar http://localhost:7351/Page works and provides layout but obviously no View. If I post the form in http://localhost:7351/Main the browser URL changes to http://localhost:7351/Site/Page and displays the results without any layout.

Form in view Main

<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" the 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 that i'm missing or don't understand.

share|improve this question
    
How does your View actually look like? Do you have a _ViewStart.cshtml page? – haim770 May 12 at 7:22
    
No I don't have that I'll edit and add the view I'm trying to render – redM May 12 at 7:32
    
When you access the /Site/Main (for example) normally using the location bar, does the Layout being included? – haim770 May 12 at 7:32
    
yeah, all other views do include the layout – redM May 12 at 7:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.