13.4. What a State

ASP.NET MVC does not use viewstate. Viewstate is used in ASP.NET WebForms applications to maintain the state of controls such as the item that is selected in a drop-down menu between page posts.

By default in ASP.NET, all controls have viewstate, which can bloat pages and slow an application down. Viewstate is often unnecessary; by removing it, you can reduce page size and increase the speed of the application because the web server no longer has to parse it and load control state.

Partly because of the lack of viewstate (and because it is kind of missing the point of ASP.NET MVC), you probably should not be using standard ASP.NET controls such as <asp:hyperlink /> in your MVC application. That's not to say these controls and tags will not work (though most won't because they require a server-side form and ASP.NET MVC doesn't use server-side forms), but it is not keeping with the clean ASP.NET MVC way of doing things, so don't do it! As you will see later in the chapter, ASP.NET MVC offers many ways of writing HTML.

As you can imagine, the lack of viewstate can be problematic—after all, ASP.NET's developers did not add it without reason! Imagine, for example, creating a new data paging, orderable data grid control without viewstate, and you can see that ASP.NET MVC also has the potential to complicate your life!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.239.254