Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stateless asp.net application and ViewState

Microsoft document http://www.asp.net/aspnet/overview/developing-apps-with-windows-azure/building-real-world-cloud-apps-with-windows-azure/web-development-best-practices encourages to keep web application stateless, however mentions also that real-world applications need to store data and it is suggested to

"not to store it on the web server. You can store state in other ways, such as on the client in cookies or out of process server-side in ASP.NET session state using a cache provide".

Following this logic, is using ViewState in ASP.Net Web Forms application stateful of stateless approach? It is kept at client side, same as mentioned cookies. Let's assume ideal scenario where I do not use any Session and Application to store data.

like image 632
Megrez7 Avatar asked Aug 16 '26 19:08

Megrez7


2 Answers

Sure; using ViewState is just like using cookies in terms of statelessness.

Be aware that Web Forms are an out-dated technology that MS and the development community has moved away from. You should look in Razor templating which a much more lightweight and flexible approach to rendering asp.net web applications.

Bloat is a big problem with the amount of data saved in ViewState, While this is probably OK if you are creating an departmental CRUD application, it probably won't fly for something targeting mobile devices.

Also, Web Forms produce very idiosyncratic HTML which makes it difficult to use modern client side technologies.

Here's a link to a pretty good article on the ascent of razor templating and the decline of web forms.

like image 180
Robert Moskal Avatar answered Aug 19 '26 09:08

Robert Moskal


The term "ViewState" has "state" in it, therefore it is by definition considered to provide the state of the view. Unlike cookies, however, ViewState provides state for only the view, not any other page or session. Cookies can be used in future sessions, ViewState only in the current instance of the view. To the extent that ViewState is lost when the page is gone, ViewState is not kept client-side. The primary purpose of ViewState is to preserve the state across post-backs, not for use anywhere else outside of the page.

like image 21
user34660 Avatar answered Aug 19 '26 08:08

user34660



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!