ASP.NET Core is a free and open-source framework which is widely adopted for its easy updates, high-speed performance, and command line application that allows it to execute, create, and host several applications, easy maintenance, and cross-platform capabilities. We have compiled a few questions and answers on ASP.NET which will help you to showcase your knowledge to your employer on concepts which lie around it. The following interview questions for ASP.NET will surely help you to prepare and qualify for your ASP Net Core developer role.
2. Server side:
In ASP.NET ViewState the values are encrypted and stored in a hidden field ( named _VIEWSTATE) on the page as an encoded Base64 string. By default, ViewState is sent to the client browser and then returned to the server in the form of a hidden input control on your page.
If the application is storing a lot of data in ViewState it can affect the overall responsiveness of the page, thereby affecting performance since data is stored on the page itself in hidden controls.
The ideal size of ViewState should be less than 30% of the page size.
DeflateStream and GZipStream are the classes in ASP.NET that provides methods and properties to compress and decompress streams. Using these classes to compress ViewState will reduce its size to around 40%.
It keeps a copy of the response that was sent to the client in memory and subsequent requests are then responded with the cached output until the cache expires, which incredibly improves the ASP.NET web application performance. It is implemented by placing an OutputCache directive at the top of the .aspx page at design time.
Example: <%@OutputCache Duration="10" VaryByParam= "Id"%>
Sometimes we might want to cache just portions of a page. For example, we might have a header for our page which will have the same content for all users. To specify that a user control should be cached, we use the @OutputCache directive just like we used it for the page.
<%@OutputCache Duration=10 VaryByParam="None" %>
Data Cache is used to store frequently used data in the Cache memory. It's much efficient to retrieve data from the data cache instead of database or other sources. We need use System.Web.Caching namespace. The scope of the data caching is within the application domain unlike "session". Every user can able to access these objects.
Create: Cache["Employee"] ="DatasetName";
Retrieve: Dataset dsEmployee = (Dataset) Cache ["Employee"]
Output cache functionality is achieved using the OutputCache attribute in the ASP.NET page header. Below is the syntax:
<%@ OutputCache Duration="20" Location="Server" Vary By Param="state" Vary By Custom="minor version" Vary By Header="Accept-Language"%>
Vary By Param - Caches different versions depending on input parameters sent through HTTP POST/GET.
Vary By Header - Caches different versions depending on the contents of the page header.
Vary By Custom - Lets you customize the way the cache handles page variations by declaring the attribute and overriding the Get Vary By Custom string handler.
Vary By Control - Caches different versions of a user control based on the value of properties of ASP objects in the control.
Cookie is a small piece of information stored on the client machine. This file is located on client machines "C:\Document and Settings\Currently_Login user\Cookie" path. It is used to store user preference information like Username, Password, City and PhoneNo etc. on client machines. We need to import namespace called System.Web.HttpCookie before we use a cookie.
50 Cookies per domain, with a maximum of 4 KB per cookie (or even 4 KB in total). If you want to support most browsers, then do not exceed 50 cookies per domain and 4093 bytes per domain. That is, the size of all cookies should not exceed 4093 bytes.
By using HttpCookie class object. After creating cookie it will be attached to Response Object to send it to the client.
HttpCookie cookie1=new HttpCookie ("Username","Ritu"); Response.Cookies.Add (cookie1);
ASP NET Core developers are sought after by companies for their niche skill sets. These interview questions on ASP.NET will give you a fair idea of the questions which the interviewer asks during an ASP.NET interview. So, prepare well and good luck!
We can cache multiple response from a single web form by using any one of the attributes from VaryByParam, VaryByHeaders or VaryByCustom attributes.
Example: If we want display different country data on our page where we can choose country name from the drop down list. On SelectedIndexChanged event of the Drop down we have to write some logic to fetch the country data according to the selected value and display the data of the particular country. By setting the VaryByParam attribute to the dropdown will cache all the responses received from server on SelectedIndexChanged event of drop down.
<%@ OutputCache Duration="20" Location="Server" VaryByParam="countryDropDown%> <aspx:DropDownList ID="countryDropDown" AutoPostBack="true" runat="server" onselectedindexchanged=" countryDropDown _SelectedIndexChanged"> <asp:ListItem Text="Germany" Value=" Germany "></asp:ListItem> <asp:ListItem Text="Singapore" Value=" Singapore "></asp:ListItem> <asp: ListItem Text="India" Value=" India "></asp: ListItem> </asp:DropDownList>
ASP.NET Core is a free and open-source framework which is widely adopted for its easy updates, high-speed performance, and command line application that allows it to execute, create, and host several applications, easy maintenance, and cross-platform capabilities. It is a framework of the future and there is a huge demand for professionals in this field.
Won’t a set of detailed FAQs boost your confidence to crack your ASP.NET interview? We have compiled a few questions and answers on ASP.NET which will help you to showcase your knowledge to your employer on concepts which lie around it. The following interview questions for ASP.NET will surely help you to prepare and qualify for your ASP Net Core developer role.