
Domains
Agile Management
Master Agile methodologies for efficient and timely project delivery.
View All Agile Management Coursesicon-refresh-cwCertifications
Scrum Alliance
16 Hours
Best Seller
Certified ScrumMaster (CSM) CertificationScrum Alliance
16 Hours
Best Seller
Certified Scrum Product Owner (CSPO) CertificationScaled Agile
16 Hours
Trending
Leading SAFe 6.0 CertificationScrum.org
16 Hours
Professional Scrum Master (PSM) CertificationScaled Agile
16 Hours
SAFe 6.0 Scrum Master (SSM) CertificationAdvanced Certifications
Scaled Agile, Inc.
32 Hours
Recommended
Implementing SAFe 6.0 (SPC) CertificationScaled Agile, Inc.
24 Hours
SAFe 6.0 Release Train Engineer (RTE) CertificationScaled Agile, Inc.
16 Hours
Trending
SAFe® 6.0 Product Owner/Product Manager (POPM)IC Agile
24 Hours
ICP Agile Certified Coaching (ICP-ACC)Scrum.org
16 Hours
Professional Scrum Product Owner I (PSPO I) TrainingMasters
32 Hours
Trending
Agile Management Master's Program32 Hours
Agile Excellence Master's ProgramOn-Demand Courses
Agile and ScrumRoles
Scrum MasterTech Courses and Bootcamps
Full Stack Developer BootcampAccreditation Bodies
Scrum AllianceTop Resources
Scrum TutorialProject Management
Gain expert skills to lead projects to success and timely completion.
View All Project Management Coursesicon-standCertifications
PMI
36 Hours
Best Seller
Project Management Professional (PMP) CertificationAxelos
32 Hours
PRINCE2 Foundation & Practitioner CertificationAxelos
16 Hours
PRINCE2 Foundation CertificationAxelos
16 Hours
PRINCE2 Practitioner CertificationSkills
Change ManagementMasters
Job Oriented
45 Hours
Trending
Project Management Master's ProgramUniversity Programs
45 Hours
Trending
Project Management Master's ProgramOn-Demand Courses
PRINCE2 Practitioner CourseRoles
Project ManagerAccreditation Bodies
PMITop Resources
Theories of MotivationCloud Computing
Learn to harness the cloud to deliver computing resources efficiently.
View All Cloud Computing Coursesicon-cloud-snowingCertifications
AWS
32 Hours
Best Seller
AWS Certified Solutions Architect - AssociateAWS
32 Hours
AWS Cloud Practitioner CertificationAWS
24 Hours
AWS DevOps CertificationMicrosoft
16 Hours
Azure Fundamentals CertificationMicrosoft
24 Hours
Best Seller
Azure Administrator CertificationMicrosoft
45 Hours
Recommended
Azure Data Engineer CertificationMicrosoft
32 Hours
Azure Solution Architect CertificationMicrosoft
40 Hours
Azure DevOps CertificationAWS
24 Hours
Systems Operations on AWS Certification TrainingAWS
24 Hours
Developing on AWSMasters
Job Oriented
48 Hours
New
AWS Cloud Architect Masters ProgramBootcamps
Career Kickstarter
100 Hours
Trending
Cloud Engineer BootcampRoles
Cloud EngineerOn-Demand Courses
AWS Certified Developer Associate - Complete GuideAuthorized Partners of
AWSTop Resources
Scrum TutorialIT Service Management
Understand how to plan, design, and optimize IT services efficiently.
View All DevOps Coursesicon-git-commitCertifications
Axelos
16 Hours
Best Seller
ITIL 4 Foundation CertificationAxelos
16 Hours
ITIL Practitioner CertificationPeopleCert
16 Hours
ISO 14001 Foundation CertificationPeopleCert
16 Hours
ISO 20000 CertificationPeopleCert
24 Hours
ISO 27000 Foundation CertificationAxelos
24 Hours
ITIL 4 Specialist: Create, Deliver and Support TrainingAxelos
24 Hours
ITIL 4 Specialist: Drive Stakeholder Value TrainingAxelos
16 Hours
ITIL 4 Strategist Direct, Plan and Improve TrainingOn-Demand Courses
ITIL 4 Specialist: Create, Deliver and Support ExamTop Resources
ITIL Practice TestData Science
Unlock valuable insights from data with advanced analytics.
View All Data Science Coursesicon-dataBootcamps
Job Oriented
6 Months
Trending
Data Science BootcampJob Oriented
289 Hours
Data Engineer BootcampJob Oriented
6 Months
Data Analyst BootcampJob Oriented
288 Hours
New
AI Engineer BootcampSkills
Data Science with PythonRoles
Data ScientistOn-Demand Courses
Data Analysis Using ExcelTop Resources
Machine Learning TutorialDevOps
Automate and streamline the delivery of products and services.
View All DevOps Coursesicon-terminal-squareCertifications
DevOps Institute
16 Hours
Best Seller
DevOps Foundation CertificationCNCF
32 Hours
New
Certified Kubernetes AdministratorDevops Institute
16 Hours
Devops LeaderSkills
KubernetesRoles
DevOps EngineerOn-Demand Courses
CI/CD with Jenkins XGlobal Accreditations
DevOps InstituteTop Resources
Top DevOps ProjectsBI And Visualization
Understand how to transform data into actionable, measurable insights.
View All BI And Visualization Coursesicon-microscopeBI and Visualization Tools
Certification
24 Hours
Recommended
Tableau CertificationCertification
24 Hours
Data Visualization with Tableau CertificationMicrosoft
24 Hours
Best Seller
Microsoft Power BI CertificationTIBCO
36 Hours
TIBCO Spotfire TrainingCertification
30 Hours
Data Visualization with QlikView CertificationCertification
16 Hours
Sisense BI CertificationOn-Demand Courses
Data Visualization Using Tableau TrainingTop Resources
Python Data Viz LibsCyber Security
Understand how to protect data and systems from threats or disasters.
View All Cyber Security Coursesicon-refresh-cwCertifications
CompTIA
40 Hours
Best Seller
CompTIA Security+EC-Council
40 Hours
Certified Ethical Hacker (CEH v12) CertificationISACA
22 Hours
Certified Information Systems Auditor (CISA) CertificationISACA
40 Hours
Certified Information Security Manager (CISM) Certification(ISC)²
40 Hours
Certified Information Systems Security Professional (CISSP)(ISC)²
40 Hours
Certified Cloud Security Professional (CCSP) Certification16 Hours
Certified Information Privacy Professional - Europe (CIPP-E) CertificationISACA
16 Hours
COBIT5 Foundation16 Hours
Payment Card Industry Security Standards (PCI-DSS) CertificationOn-Demand Courses
CISSPTop Resources
Laptops for IT SecurityWeb Development
Learn to create user-friendly, fast, and dynamic web applications.
View All Web Development Coursesicon-codeBootcamps
Career Kickstarter
6 Months
Best Seller
Full-Stack Developer BootcampJob Oriented
3 Months
Best Seller
UI/UX Design BootcampEnterprise Recommended
6 Months
Java Full Stack Developer BootcampCareer Kickstarter
490+ Hours
Front-End Development BootcampCareer Accelerator
4 Months
Backend Development Bootcamp (Node JS)Skills
ReactOn-Demand Courses
Angular TrainingTop Resources
Top HTML ProjectsBlockchain
Understand how transactions and databases work in blockchain technology.
View All Blockchain Coursesicon-stop-squareBlockchain Certifications
40 Hours
Blockchain Professional Certification32 Hours
Blockchain Solutions Architect Certification32 Hours
Blockchain Security Engineer Certification24 Hours
Blockchain Quality Engineer Certification5+ Hours
Blockchain 101 CertificationOn-Demand Courses
NFT Essentials 101: A Beginner's GuideTop Resources
Blockchain Interview QsProgramming
Learn to code efficiently and design software that solves problems.
View All Programming Coursesicon-codeSkills
Python CertificationInterview Prep
Career Accelerator
3 Months
Software Engineer Interview PrepOn-Demand Courses
Data Structures and Algorithms with JavaScriptTop Resources
Python TutorialProgramming
4.8 Rating 28 Questions 24 mins read7 Readers

2. Server side:
ViewState is a client-side state management mechanism in ASP.NET. It is a default technique used by ASP.NET to persist the value of the page and controls during postbacks.
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.
Advantages:
Disadvantages:
It's no surprise that this one pops up often in ASP.NET interview questions and answers for freshers.
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 provide 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.
A staple in ASP.NET interview questions for advance professionals, be prepared to answer this one.
While programming in C#, we can split the definition of a class over two or more source files. The source files contain a section of the definition of class, and all parts are combined when the application is compiled. For splitting a class definition, we need to use the partial keyword.
Example:
We have a file with a partial class named as Record
namespace HeightWeightInfo
{
class File1
{
}
public partial class Record
{
private int h;
private int w;
public Record(int h, int w)
{
this.h = h;
this.w = w;
}
}
}Here is another file named as File2.cs with the same partial class Record
namespace HeightWeightInfo
{
class File2
{
}
public partial class Record
{
public void PrintRecord()
{
Console.WriteLine("Height:"+ h);
Console.WriteLine("Weight:"+ w);
}
}
}The main method of the project
namespace HeightWeightInfo
{
class Program
{
static void Main(string[] args)
{
Record myRecord = new Record(10, 15);
myRecord.PrintRecord();
Console.ReadLine();
}
}
}State management basically stores the information of user/Page or object when a user makes a request on a web page, since HTTP is a protocol which doesn’t store the information during each request made by the user.so Asp.net state management is used to preserve the data.
Server Side:-
1) Session: when we want to store the data of web page over multiple requests we use session. In this technique we can store any kind of information or object in server memory it basically stores the information. The session is user specific since it stores the information of user separately. When we store data to Session state, a session cookie named is ASP.NET_SessionId is created automatically.
Example:
Storing the data in Session object
Session ["UserName"] = txtName.Text;
Retrieving the data from the Session object
Label1.Text = Session ["UserName"].ToString();
Session timeout is 20 min if we want to increase the timeout of session then we need to configure the web config
<configuration>
<system.web>
<sessionState timeout="60" />
</system.web>
</configuration>
2). Application object: In application object, we can store the information at the application level rather than User level, where every user can access that information .the main disadvantage is that sometimes there is a concurrency problem, so for that, we use a lock and unlock method. So if multiple requests came for same data then only one thread can do work.
Example:
Application["Message"] = "Hello to all";
We can use an application object to count the number of visitors on that website.
Client Side:
1) Query Strings: When we want to transfer the data over the pages from the URL then we use query string, it cannot handle the huge data and it is compatible with all browsers, we cannot transfer the objects and controls in query strings, so it is not meant for transferring sensitive data through query string.
Example:
Response.Redirect( "SecondPage.aspx?Type=01&Query=Query1" );
Or if we want to use query string to transfer the data then we can encrypt the sensitive data and we can transfer the data.
2). Control State: It is used to transfer the data which is stored in controls .it is just like same as view state but here we can store the data of the controls like dropdown list`s selected items, we cannot disabled the control state if viewstate is disabled then control state works same as view state.
3). View State: It is one of the finest methods to preserve the data, in view state we can store any kind of data like controls data, and even variables and raw data, view state encrypt the data when it will render to the user, so if user wants to see the value of view state in view source it will contain the symbols only which are very hard to decrypt.
The only disadvantage is that page contains much space over the page. To handle the view state we just need to "EnableViewState = true" attribute to any control to save its state,
Example:
public class Person
{
public string FirstName {get;set;}
public string LastName {get;set;}
}
public partial class default : Web.UI.Pages
{
Person p = new Person();
p.FirstName = "Harshit";
p.LastName = "Mittal";
ViewState["PersonDetails"]=p;
}
4). Cookies: Cookies are used to identify the user on a web page whenever the user makes the request for the first time it stores that request data in the cookies and when the user visit that web page for the second time then browser check the cookies data with second request data made by the user if the result matches browser to consider them as a previous user else consider a new user.
Example: The Case of Remember me on every login page.
There are 2 types of cookies:
Example:
Response.Cookies["nameWithPCookies"].Value = "This is A Persistence Cookie";
Response.Cookies["nameWithPCookies"].Expires = DateTime.Now.AddSeconds(10);
Example:
Response.Cookies["nameWithNPCookies"].Value = "This is A Non Persistence Cookie";
5) Hidden Field - When we want to store the small amount of data or we can say the if want to save the single value, hidden field controls is not rendered on the client browser, it is invisible to the browser.
Example:
<asp:HiddenField ID="HiddenField1" runat="server" />
At the server code
protected void Page_Load(object sender, EventArgs e)
{
if (HiddenField1.Value != null)
{
int val= Convert.ToInt32(HiddenField1.Value) + 1;
HiddenField1.Value = val.ToString();
Label1.Text = val.ToString();
}
}
| Hashtable | Dictionary |
|---|---|
| Hashtable included in System.Collections namespace | Dictionary included in System.Collections.Generic namespace |
| It is weakly structured data type in key values pair we can take any object type | In this strong in a data type that you must have to specify the data type of the key value pair |
| Returns null as a result if key which does not exist | Throws exception if we try to find with a key that not exists |
| It is generic type | It is non-generic type |
| It is faster since we don’t need to do boxing and unboxing in this | It is slower than hashtable and it involves an additional step of boxing and unboxing |
| Response.Redirect | Server.Transfer |
|---|---|
| when we want to transfer the information from one page to another page of the same server | when we want to transfer the data to an HTML page of own server or to some other server |
| it doesn’t require the query string to preserve the data | It never persists Query Strings and Forms Variables from original request |
| It causes additional round trips to the server on each request | It preserves server resources and avoids the unnecessary round trips to the server |
| In this, we need to show the URL to the user where we are redirecting | the current URL where the page is redirected is not shown in the browser |
This question is a regular feature in ASP.NET interview questions for senior developer, be ready to tackle it.
As we know we cannot assign the null value to any value type so for that we use nullable type where we can assign null value to the value type variables.
Syntax:
Nullable<T> where T is a type. Nullable type is an instance of System.Nullable<T> struct
Nullable Struct :
[Serializable]
public struct Nullable<T> where T : struct
{
public bool HasValue { get; } // it will return true if we assigned a value, if there is no value or if we assign a null value it will return false;
public T Value { get; }
}
HasValue :
static void Main(string[] args)
{
Nullable<int> i = null;
if (i.HasValue)
Console.WriteLine(i.Value);
else
Console.WriteLine("Null");
}Example:
[Serializable]
public struct Nullable<T> where T : struct
{
public bool HasValue { get; }
public T Value { get; }
}
static void Main(string[] args)
{
Nullable<int> i = null;
if (i.HasValue)
Console.WriteLine(i.Value); // or Console.WriteLine(i)
else
Console.WriteLine("Null");
}Output:
Null
It will check whether an object has been assigned a value if it is having null value it will return false and the else part will be executed.
To get the value of i using the nullable type you have to use GetValueOrDefault() method to get the actual value.
static void Main(string[] args)
{
Nullable<int> i = null;
Console.WriteLine(i.GetValueOrDefault());
}Extension methods allow you to add our own custom method in any custom class without modifying into it and in our custom class and it will be available throughout the application by specifying namespace only where it is defined.
Example:
namespace ExtensionMethod
{
public static class IntExtension
{
public static bool IsGreaterThan(this int i, int value)
{
return i > value;
}
}
}Here the first parameter specifies the type on which the extension method is applicable. We are going to use this extension method on int type. So the first parameter must be int preceded with the modifier.
using ExtensionMethod;
class Program
{
static void Main(string[] args)
{
int i = 10;
bool result = i.IsGreaterThan(100);
Console.WriteLine(result);
}
}Output:
False
In Throw, the original exception stack information is retained.
Example:
For Throw :
try
{
// some operation that can fail
}
catch (Exception ex)
{
throw;
}For Throw Ex:
In Throw Ex the original information is overridden by the External information and you will lose the original information.
try
{
// do some operation that can fail
}
catch (Exception ex)
{
// do some local cleanup
throw;
}