c# - ASP.NET application performing full page reload on each request -
i expected web application behave "single page app", in entire screen not turn white between each page load, rather render new section of page per:
<div id="mainsection"> <!-- render individual pages --> @renderbody() </div>
and links on _layout.cshtml
page:
<li>@html.actionlink("some page", "index", "page")</li>
now 1 other point application appears behave correctly in firefox only. application not perform full page reload in firefox, in chrome or ie does. application running on iis.
@html.actionlink
helper method creates link url particular controller , action (so don't have hard-code urls everywhere.)
it produces link that's pretty other:
<a href="/page/index">some page</a>
so it's expected clicking on should load page in browser, if it's page you're on. (like if click on stackoverflow logo on , on - it's going keep reloading same page.)
what's peculiar it's not doing reload in firefox. sure it's not loading fast?
when 1 of views uses layout, @renderbody()
in layout tells render view within layout. that's specifying how page fits layout, doesn't mean part going reload.
try this link you're trying do.
- in javascript, make ajax call controller
- the controller renders partial view (a view no layout) , returns html result of ajax call
- your javascript gets result of ajax call , replaces contents of
<div>
new html.
that way page never refreshes, instead 1 part of gets updated.
then there sorts of javascript libraries angularjs automate you. i'd recommend getting own first test case working can see how it's happening before moving on else.
Comments
Post a Comment