https://www.aspsnippets.com/Articles/Create-dynamic-ASPX-Page-on-the-Fly-in-ASPNet-using-C-and-VBNet.aspx
https://www.c-sharpcorner.com/UploadFile/00a8b7/interview-questions-for-2-year-experience-in-sql-and-C-Sharp/
https://www.c-sharpcorner.com/UploadFile/00a8b7/interview-questions-for-2-year-experience-in-sql-and-C-Sharp/
Question 1: When does a session actually start?
Answer:- A session actually starts when a visitor requests your site for the first time. A new session starts when the request doesn't contain any SessionID or the sessionID references an expired session. The Session_OnStart event in Global.asax can be used for tracking session-related information.
Question 3: How is a
session maintained?
Question 3: What are
the various session modes in ASP.NET?
In-proc: Session data is stored in the same machine as
that of the server. So session data is lost, when the server restarts. Session
data is overhead on the server.
State server: Session data is stored in a separate machine.
SQL Server: Session data is stored in a SQL Server database and kept
centrally.
Question 2: Why do we need Http handlers and models?
Answer
Question 4: Session.Abandon() vs Clear() ,?
Session.Abandon() destroys the current session by firing a Session_End event. It releases the SessionState object and its items
to free the resources.
Session.Clear(
) just clears the session data
(gives a null
value to the session) without
killing it. It still holds the SessionState and resources associated with it.
Session ID will remain the same in both of the
cases as long as the browser is not closed.
Question 17: What are
the various ways to send content from one page to another?
Ø Response. Redirect()
Server.Transfer()
WebClient.DownloadFile()
Server.Transfer()
WebClient.DownloadFile()
Question 18: How to
call a code behind method asynchronously.?
1. Create a public static method and decorate it
with the WebMethod Attribute.
2.Add an asp:ScriptManager
control with “EnablePageMethods = true”
in the aspx page.
3.Now either you can make a jQuery
ajax request to it or can call from JavaScript using the PageMethods class.
- [WebMethod]
- public static string Operate()
- {
- return “Hi”;
- }
-
- <asp:ScriptManager runat=”server” EnablePageMethods = true></asp:ScriptManager>
-
- Window.PageMethods.Operate();
Question 19: What does
asp:ScriptManager do to call a WebMethod?
Answer
JavaScript proxies are automatically generated by the ScriptManager that can call the page methods in the code-behind page. The proxy is accessed on the client-side using a special class generated by the ScriptManager called PageMethods.
Answer
JavaScript proxies are automatically generated by the ScriptManager that can call the page methods in the code-behind page. The proxy is accessed on the client-side using a special class generated by the ScriptManager called PageMethods.
Question 20: What are
all the things that AJAX can't do?
Answer
- AJAX is not supported by old
browsers that don't support the XMLHttpRequest JavaScript object.
- AJAX will not work if
JavaScript is disabled in the browser.
- Back functionality will not
work with ajax since dynamic pages
don't register themselves with the browser history engine.
- If the page is bookmarked, the content
implemented with AJAX will not reflect.
Question 21: What
are Session Modes advantages over the others?
·
InProc: Session data is stored in the same web server. Performance-wise it's the best
mode. But session data will be lost
once the server is restarted. Again,
since session data is stored in the same server, it’s an overhead on the server, so more data can’t be saved in the session.
StateServer: Session data is serialized and stored in a separate server so an issue with IIS will not hamper the session data. The aspnet_state.exe service needs to be up and running. Due to serialization and de-serialization, performance-wise it’s slow.
SqlServer: This is a secure and reliable mode. Session data is serialized and saved in a SQL Server database. The overhead is with serializing and de-serializing data. Since data is stored in the database, it’s centrally available. This is preferred if frequent server restarts are needed or data must be shared with multiple servers.
StateServer: Session data is serialized and stored in a separate server so an issue with IIS will not hamper the session data. The aspnet_state.exe service needs to be up and running. Due to serialization and de-serialization, performance-wise it’s slow.
SqlServer: This is a secure and reliable mode. Session data is serialized and saved in a SQL Server database. The overhead is with serializing and de-serializing data. Since data is stored in the database, it’s centrally available. This is preferred if frequent server restarts are needed or data must be shared with multiple servers.
Question 30: Describe the Page life cycle
Answer
PreInit:
Check the IsPostBack
property to determine whether this is the first time the page is being
processed.
Create or
re-create dynamic controls.
Set a master
page dynamically.
Set the Theme
property dynamically.
Note
If the request is a postback then the values of the
controls have not yet been restored from the view state
Init: Each controls the UniqueID set. This event is fired first for the inner-most element in the DOM, then the parent controls and finally for the page itself.
InitComplete: Changes to the view state and any functionality that requires all the controls to be loaded can be done here.
PreLoad: ViewState of the page and all the controls are loaded. Postback data is also loaded.
Raised
after the page loads view state for itself and all controls, and after it
processes postback data that is included with the Request instance.
Load: The Load event is raised for the page object itself and then recursively for all the child controls until the page itself and all it’s controls are loaded.
Dynamic controls can be created here.
IsPostBack andIsValid values can be checked to avoid redundant code.
Here all the control values are restored.
PreRender: Allows final changes to the page and it’s controls. This event is fired for the page first and then for the controls.
Render: Generates the client-side HTML, DHTML and script that are necessary to display the page on the browser.
UnLoad: This event is fired for the controls and then for the page itself. All the unused objects are disposed.
Question 32: What does
AutoEventWireUp in the page directive tag mean?
If “AutoEventWireUp = true”, you don’t need to attach event handlers to the events. Automatically, the event handler will be executed when the event fires up. You just need to override the required event handler.
If “AutoEventWireUp = true”, you don’t need to attach event handlers to the events. Automatically, the event handler will be executed when the event fires up. You just need to override the required event handler.
Question 33: If you
have 10 users requesting your application, how many times Application_Start
event will be fired?
Application_Start will be fired only once at the application level. In other words, when the application is requested for the first
time.
Question 34: Property vs field.?
Fields are private
elements whereas properties are public elements with getter and/or
setter.
Question 1: What is ASP.NET?
ASP.NET
is Microsoft's framework to build Web applications. ASP.NET is a part of .NET
Framework. ASP.NET and Web Forms are used to build the front end and in the
backend, C# langauge is used. ASP.NET runs on a Web Server, IIS.
Advantages of ASP.NET
- Separation of Code from
HTML:
- Support for compiled
languages:
- Use services provided by the
.NET Framework:
- Graphical Development
Environment:
- State management:
- Update files while the server
is running:
- XML-Based Configuration Files
Question 2: What are the different validators in ASP.NET?
Answer: validating the user input data.
- Client-Side Validation
- Server-Side Validation
Client-Side Validation:
When validation is done on the client browser,
then it is known as Client-Side Validation. We use JavaScript to do the
Client-Side Validation.
Server-Side Validation:
When validation occurs on the server, then it is known as Server-Side Validation. Server-Side Validation is a secure form of validation. The main advantage of Server-Side Validation is if the user somehow bypasses the Client-Side Validation, we can still catch the problem on server-side.
The following are the Validation Controls in ASP.NET:
Server-Side Validation:
When validation occurs on the server, then it is known as Server-Side Validation. Server-Side Validation is a secure form of validation. The main advantage of Server-Side Validation is if the user somehow bypasses the Client-Side Validation, we can still catch the problem on server-side.
The following are the Validation Controls in ASP.NET:
- RequiredFieldValidator Control
- CompareValidator Control
- RangeValidator Control
- RegularExpressionValidator
Control
- CustomFieldValidator Control
- ValidationSummary
Question 3: What is View State?
Answer: View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.
A web application is stateless. That means that a new instance of a page is created every
time when we make a request to the server
to get the page and after the round trip our page has been lost
immediately
Features of View State
These are the main features of view state:
These are the main features of view state:
- Retains the value of the
Control after post-back without
using a session.
- Stores the value of Pages and Control Properties defined in the page.
- Creates a custom View State
Provider that lets you store View State Information in a SQL Server
Database or in another data store.
Advantages of View State
- Easy to Implement.
- No server resources are
required: The View State is
contained in a structure within the page load.
- Enhanced security features: It
can be encoded and compressed or Unicode implementation.
Question 4: What are the different Session state management options
available in ASP.NET?
Answer: State Management in ASP.NET
- A new instance of the Web page
class is created each time the page is posted to the server.
- In traditional Web programming,
all information that is associated with the page, along with the controls
on the page, would be lost with each roundtrip.
- The Microsoft ASP.NET framework
includes several options to help you preserve data on both a per-page
basis and an application-wide basis.
These options can be broadly divided into the following two categories:
- Client-Side State Management
Options
- Server-Side State Management
Options
Client-Side State Management
- Client-based options involve
storing information either in the page or on the client computer.
- Some client-based state
management options are:
- Hidden fields
- View state
- Cookies
- Query strings
Server-Side State Management
- There are situations where you
need to store the state information on the server side.
- Server-side state management
enables you to manage application-related and session-related information
on the server.
- ASP.NET provides the following
options to manage state at the server side:
- Application state
- Session state

For further information click on the link:
Question 5: What is caching in ASP.NET?
Answer: Caching is one of the most interesting concept and operation in ASP.NET. If you can handle it, you can run any web application by applying the caching concept depending on the requirements.
Caching is for providing solutions or the results to the users depending on their request, admin needs to recreate the pages often depending on user requests…STOP!!! "A cache simply stores the output generated by a page in the memory and this saved output (cache) will serve us (users) in the future.".
Types
Paging Caching
fragment Caching
data Caching

Question 6: How can we apply themes in ASP.NET application?
Answer: A theme is a collection of settings that define the look of controls and web pages. These themes are applied across all the pages in a web application to maintain a consistent appearance. Themes are included images and
skin
files; the
skin files set the visual properties of ASP.NET controls. Themes are of two
types:
Page Theme
A Page theme contains the control skins, style sheets, graphic files, and other resources inside the subfolder of the App_Theme folder in the Solution Explorer window. A page theme is applied to a single page of the web site.
Global Theme
A Global theme is a theme that is applied to all the web sites on a web server and includes property settings, and graphics. This theme allows us to maintain all the websites on the same web server and define the same style for all the web pages of the web sites.
Page Theme
A Page theme contains the control skins, style sheets, graphic files, and other resources inside the subfolder of the App_Theme folder in the Solution Explorer window. A page theme is applied to a single page of the web site.
Global Theme
A Global theme is a theme that is applied to all the web sites on a web server and includes property settings, and graphics. This theme allows us to maintain all the websites on the same web server and define the same style for all the web pages of the web sites.
Question 8: What are Cookies in ASP.NET?
Answer: Cookies are a State Management Technique that can store the values of control after a post-back. Cookies can store user-specific Information on the client's machine like when the user last visited your site. Cookies are also known by many names, such as HTTP Cookies, Browser Cookies, Web Cookies, Session Cookies and so on. Basically cookies are a small text file sent by the web server and saved by the Web Browser on the client's machine.
List of properties containing the HttpCookies Class:
- Domain: Using these properties we can set the domain of
the cookie.
- Expires: This property sets the Expiration time of the
cookies.
- HasKeys: If the cookies have a subkey then it returns True.
- Name: Contains the name of the Key.
- Path: Contains the Virtual Path to be submitted with the
Cookies.
- Secured: If the cookies are to be passed in a secure
connection then it only returns True.
- Value: Contains the value of the cookies.
Limitation of the Cookies
- The size of cookies is limited
to 4096 bytes.
- A total of 20 cookies can be
used in a single website
Question 11: What are the Advantages of ASP.NET?
Advantages of ASP.NET:
- Separation of Code from HTML
- Support for compiled languages
- Use services provided by the
.NET Framework
- Graphical Development
Environment
- Update files while the server
is running
- XML-Based Configuration Files
Question 12: What is the concepts of Globalization and Localization in
.NET?
Answer: Localization means "process of translating resources for a specific culture", and Globalization means "process of designing applications that can adapt to different cultures".
- Proper Globalization: Your application should be able to Accept, Verify, and
Display all global kind of data. It should well also be able to operate
over this data, accordingly. We will discuss more about this "Accordingly
operations over diff. culture data".
- Localizability and
Localization: Localizability stands for
clearly separating the components of culture based operations regarding
the user interface, and other operations from the executable code.
.NET framework has greatly simplified the task
of creating the applications targeting the clients of multiple cultures. The
namespaces involved in creation of globalize, localizing applications are:
- System.Globalization
- System.Resources
- System.Text
Question 13: What is the Web.config file in ASP?
Answer: Configuration file is used to manage various settings that define a website. The settings are stored in XML files that are separate from your application code. In this way you can configure settings independently from your code. Generally a website contains a single Web.config file stored inside the application root directory. However there can be many configuration files that manage settings at various levels within an application.
Usage of configuration file
ASP.NET Configuration system is used to describe the properties and behaviors of various aspects of ASP.NET applications. Configuration files help you to manage the settings related to your website. Each file is an XML file (with the extension .config) that contains a set of configuration elements. Configuration information is stored in XML-based text files.
Benefits of XML-based Configuration files:
- ASP.NET Configuration system is
extensible and application specific information can be stored and
retrieved easily. It is human readable.
- You need not restart the web
server when the settings are changed in configuration file. ASP.NET
automatically detects the changes and applies them to the running ASP.NET
application.
- You can use any standard text
editor or XML parser to create and edit ASP.NET configuration files.
Question 14: What is the App Domain Concept in ASP.NET?
Answer: ASP.NET introduces the concept of an Application Domain which is shortly known as AppDomain. It can be considered as a Lightweight process which is both a container and boundary. The .NET runtime uses an AppDomain as a container for code and data, just like the operating system uses a process as a container for code and data. As the operating system uses a process to isolate misbehaving code, the .NET runtime uses an AppDomain to isolate code inside a secure boundary.
The CLR can allow the multiple .NET applications to run in a single AppDomain. Mulitple Appdomains can exist in Win32 process.
How to create AppDomain: AppDomains are created using the CreateDomain method. AppDomain instances are used to load and execute assemblies (Assembly). When an AppDomain is no longer in use, it can be unloaded.
- public class MyAppDomain: MarshalByRefObject
- {
- public string GetInfo()
- {
- return AppDomain.CurrentDomain.FriendlyName;
- }
- }
- public class MyApp
- {
- public static void Main()
- {
- AppDomain apd = AppDomain.CreateDomain("Rajendrs Domain");
- MyAppDomain apdinfo = (MyAppDomain) apd.CreateInstanceAndUnwrap(Assembly.GetCallingAssembly()
- .GetName()
- .Name, "MyAppDomain");
- Console.WriteLine("Application Name = " + apdinfo.GetInfo());
- }
- }
Question 15: What is Query String in ASP?
Answer: A QueryString is a collection of characters input to a computer or web browser. A Query String is helpful when we want to transfer a value from one page to another. When we need to pass content between the HTML pages or aspx Web Forms in the context of ASP.NET . A Query String Collection is used to retrieve the variable values in the HTTP query string. If we want to transfer a large amount of data then we can't use the Request.QueryString. Query Strings are also generated by form submission or can be used by a user typing a query into the address bar of the browsers.
Answer: A QueryString is a collection of characters input to a computer or web browser. A Query String is helpful when we want to transfer a value from one page to another. When we need to pass content between the HTML pages or aspx Web Forms in the context of ASP.NET . A Query String Collection is used to retrieve the variable values in the HTTP query string. If we want to transfer a large amount of data then we can't use the Request.QueryString. Query Strings are also generated by form submission or can be used by a user typing a query into the address bar of the browsers.
Advantages:
- Simple to Implement
- Easy to get information from
Query string.
- Used to send or read cross
domain (from different domain).
Disadvantages:
- Human Readable
- Client browser limit on URL
length
- Cross paging functionality
makes it redundant
- Easily modified by end user