1

I'm building an MVC application and I've noticed when I navigate through the app the layout gets reloaded along with my content.

I know this is default and expected behavior.

I'd really like to avoid reloading the layout, any thoughts?

Dale K
  • 25,246
  • 15
  • 42
  • 71
Esteban
  • 3,108
  • 3
  • 32
  • 51

2 Answers2

4

You have minimum two abilities:

Main idea is load PartialView with ajax requests and insert/replace content in DOM.

Dani
  • 1,825
  • 2
  • 15
  • 29
webdeveloper
  • 17,174
  • 3
  • 48
  • 47
  • I feared that, I've done [this](http://stackoverflow.com/questions/11903078/how-to-update-my-content-async-with-javascript/11903079#11903079) function to update content async. I think I don't have many choices here. Thank you for your response. – Esteban Sep 19 '12 at 21:12
  • 1
    @Esteban If you want only content, without html-markup, then look at client templating, for example this [JsRender: Demos](http://borismoore.github.com/jsrender/demos/demos.html). Server return json and then you fill your page. – webdeveloper Sep 19 '12 at 21:26
1

There is no way to instruct it to not reload the layout

The Layout gets rendered at the backend as soon as you request the url it returns a view that it redered with the layout .

However using ajax to load your views is bad for SEO you can do some workarounds. Or should i say SEO is stupid and someone should Fix that shit.

I posted a link to show you how the crawlers act when you have a ajax website

http://moz.com/blog/how-to-allow-google-to-crawl-ajax-content

There are some great frameworks out there like Backbone , angularjs,knockout that makes it simple to accomplish what you wanto do.