QuestPond’s Interview Questions & Answers on learning Viewstate for state management, Hidden frames and Cookies in ASP.NET

What are benefits and Limitation of using Viewstate for state management?

Following are the benefits of using Viewstate:-

  • No server resources are required because state is in a structure in the page code.
  • Simplicity.
  • States are retained automatically.
  • The values in view state are hashed, compressed, and encoded, thus representing a higher state of security than hidden fields.
  • View state is good for caching data in Web frame configurations because the data is cached on the client.  

Following are limitation of using Viewstate:-

  • Page loading and posting performance decreases when large values are stored because view state is stored in the page.
  • Although view state stores data in a hashed format, it can still be tampered because it is stored in a hidden field on the page. The information in the hidden field can also be seen if the page output source is viewed directly, creating a potential security risk.

Below is sample of storing values in view state.

this.ViewState[“EnterTime”] = DateTime.Now.ToString();

How can you use Hidden frames to cache client data?

This technique is implemented by creating a Hidden frame in page which will contain your data to be cached.

<FRAMESET cols=”100%,*,*”>
<FRAMESET rows=”100%”>
<FRAME src=”data_of_frame1.html”></FRAMESET>
<FRAME src=”data_of_hidden_frame.html”>
<FRAME src=”data_of_hidden_frame.html” frameborder=”0″ noresize scrolling=”yes”>
</FRAMESET>  

Above is a sample of hidden frames where the first frame “data_of_frame1.html” is visible and the remaining frames are hidden by giving whole col section to first frame. 100 % is allocated to first frame and remaining frames thus remain hidden.

What are benefits and limitations of using Hidden frames?

Following are the benefits of using hidden frames:

  • You can cache more than one data field.
  • The ability to cache and access data items stored in different hidden forms.
  • The ability to access JScript® variable values stored in different frames if they come from the same site.  

The limitations of using hidden frames are:

  • Hidden frames are not supported on all browsers.
  • Hidden frames data can be tampered thus creating security hole.

What are benefits and limitations of using Cookies?

Following are benefits of using cookies for state management:-

  • No server resources are required as they are stored in client.
  • They are light weight and simple to use  

Following are limitation of using cookies:-

  • Most browsers place a 4096-byte limit on the size of a cookie, although support for 8192-byte cookies is becoming more common in the new browser and client-device versions available today.
  • Some users disable their browser or client device’s ability to receive cookies, thereby limiting the use of cookies.
  • Cookies can be tampered and thus creating a security hole.
  • Cookies can expire thus leading to inconsistency.

Below is sample code of implementing cookies

Request.Cookies.Add(New HttpCookie(“name”, “user1”))

See following video on importance of session and viewstate: –

 

Click and see here for more step by step learning on ASP.NET.


Advertisements

About c# and .NET Interview questions

This blog is for developers who want to crack .NET and C# interviews. It has all tips and tricks needed to crack .NET interviews , C# interview , SQL Server interview , Java interview , WCF Interview , Silverlight interview , WPF interview , LINQ interview , Entity framework Interview. Do not forget to watch our Learn step by step video series. Learn MVC in 16 hours:- https://www.youtube.com/watch?v=Lp7nSImO5vk Learn AngularJS Step by Step:- https://www.youtube.com/watch?v=0kmdjqgO9IY Learn Design Pattern in 8 hours:- https://www.youtube.com/watch?v=YDobmucohqk Learn C# and .NET in 60 days:- https://www.youtube.com/watch?v=yh2SrzCkNQA Learn MSBI in 32 hours:- https://www.youtube.com/watch?v=mGPJx3ocFgg Learn SharePoint Step by Step in 8 hours:- https://youtu.be/C2fW76SwJNU
This entry was posted in Uncategorized and tagged , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s