0% found this document useful (0 votes)
35 views

Naukri

.net questions prepared through naukri.com

Uploaded by

Prashant Solanki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Naukri

.net questions prepared through naukri.com

Uploaded by

Prashant Solanki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

ASP.

NET Interview Questions

1. What is ASP.NET?
2. What is the ASP.NET MVC framework?
3. Which would be the correct framework to be used ASP.NET MVC or ASP.NET Web API?
4. What is Server control?
5. What is Razor in ASP.NET?
6. What is the REST architecture?
7. What are the different types of Authentication in ASP.NET?
8. What is Caching and its different types?
9. What is Query String in ASP? And what are its advantages and disadvantages?
10. What does the method ‘Finalize’ do in ASP.NET?
11. What are the steps in the ASP.NET page life cycle?
12. What is the web.config file?
13. Which compiler is used in ASP.NET?
14. ASP.NET is open-source. Explain?
15. Explain the Global.asax file?
16. What all types of Server controls are supported by ASP.NET?
17. What does “PostBack” mean in ASP.NET?
18. Explain the difference between Web.config and Machine.config file?
19. Write a step for Request Flow in ASP.NET MVC framework?
20. Explain the various modes for the Session state in ASP.NET?
21. Write down different return types of a controller action method?
22. How to maintain sessions in MVC?
23. What is NuGet package manager?
24. What is the use of the Program class?
25. What is the use of the Startup class?
26. What is the use of the wwwroot folder?
27. What is the use of the appsettings.json file?
28. What is IIS?
29. What is dependency injection?
30.How does dependency injection works in ASP.NET Core?
31. What is a cookie?
32. What is the difference between Hyperlink and LinkButton?
33. What are navigation controls?
34. What are Globalization and Localization?
35. What is a Resource File?
36. What are Local Resources and Global Resources?
37. What is Neutral Culture, Culture, and Language?
38. What are the built-in objects in ASP.NET?
39. What do you mean by Role-based security?
40. What is event bubbling?
41. What is the command used to verify the presence of ASP.NET in the system?
42. What are the core sections of the ASP.NET App page?
43. What are page directives in ASP.NET App?
44. What is the response object in ASP.NET App?
ASP.NET Interview Questions
1. What is ASP.NET?
The ASP.NET is a component of the .NET Framework that may be used to build
dynamic websites, online applications, and web services. It's a server-side
technology that works with any .NET compatible languages, such as C#, VB.NET,
and J#, and compiles them to Microsoft Intermediate Language (MSIL). ASP.NET
makes it simple to create a fast and interactive application using server controls.
ASP.NET has the following features:
 It builds websites using the C# and VB.NET programming languages.
 It allows us to keep the HTML layout and server-side code separate.
 It enables us to qualify the same class name in a separate namespace.
 The pages in ASP.NET are compiled rather than interpreted.
 ASP.NET is a request processing engine. It receives an incoming request
and routes it through its internal pipeline to an endpoint to which a
developer may attach code to process it.
2. What is the ASP.NET MVC framework?
ASP.NET MVC is a lightweight web application framework with a lot of tested
features. Model, View, and Controller are the three types of components supported
by ASP.NET.
 The Model component relates to all or any of the data-related logic with
which the user interacts. This will represent the data being transmitted
between the View and Controller components, as well as any other
business logic-related data. A Customer object, for example, will retrieve
customer information from a database, change it, and either update or
output the data back to the database.
 The View component is used for all of the appliance's user interface logic.
For example, the Customer view will have all of the UI components that
the final user interacts with, such as text boxes, dropdowns, and so on.
 Controllers serve as a link between the Model and Consider components,
processing all business logic and incoming requests, manipulating data
with the Model component, and interacting with Views to render the final
output. The Customer controller, for example, will handle all interactions
and inputs from the Customer View and use the Customer Model to
update the database. The Customer data will be viewed by an analogous
controller.
3. Which would be the correct framework to be used ASP.NET
MVC or ASP.NET Web API?
ASP.Net MVC is used to create online applications that return both the view and the
data, whereas Asp.Net Web API is used to create all HTTP services in a simple and
basic approach that only returns data, not the view.
Web API allows you to create RESTful services using the.NET Framework, and it
also includes features like content negotiation and self-facilitating that aren't
available in MVC.
Web API also deals with returning information that is particularly intended, such as
JSON, XML, or another, based on the Accept header in the request, and you don't
have to worry about it. Using Json Result, MVC simply returns information in JSON
format.
4. What is Server control?
Server Controls are capabilities in ASP.NET that allow you to manipulate the values
of controls on the server side. This is extremely useful when creating verifying and
dynamically generated web forms.
5. What is Razor in ASP.NET?
Razor in ASP.NET provides the syntax for creating dynamic web pages using C#
and HTML. For SPAs, ASP.NET may be combined with JS (JavaScript) and contains
frameworks such as React and Angular (Single Page Application.)
6. What is the REST architecture?
REST is the acronym for REpresentational State Transfer. REST is an architectural
approach that follows six restrictions specified by Roy Fielding in 2000, rather than a
rigorous standard. Uniform Interface, Client-Server, Stateless, Cacheable, Layered
System, and Code on Demand are the limitations. REST is not limited to XML, and it
is up to the implementer to decide which Media-Type to use, such as XML, JSON, or
plain-text. Furthermore, REST can make use of the SOAP protocol, but SOAP
cannot make use of REST. REST is simple to set up and uses less bandwidth,
making it ideal for mobile devices.
RESTful API Architectural Constraints: The following are six architectural restrictions
that any web service must meet:
 Stateless
 Cacheable
 Client-Server
 Layered System
 Code on Demand with a Uniform Interface
7. What are the different types of Authentication in ASP.NET?
Authentication is the process of determining a user's identity based on their
credentials. Users' credentials are often in the form of a user ID and password, and
we check them against a database or equivalent alternative to see if they exist. If
they do, the user is a valid candidate for the next step - authorisation. In ASP.NET,
there are several types of authentication to choose from, including:
 Form Authentication
 Passport Authentication
 Windows Authentication
 Custom Authentication
8. What is Caching and its different types?
The caching function in Asp.Net allows you to save or cache Web Page output. This
technique is used to save time by not having to recreate the same data. In ASP.NET,
there are three different methods of caching:
 Caching of page output
 Caching of page fragments
 Caching of data
If the user requests the same data or information repeatedly, caching improves
performance.
 Caching of page output: It's done by adding an OutputCache directive to
the top of the.aspx page during the design phase.
 The Cache object implements data caching, which is useful for rapid
retrieval of application data.
 Page Fragment Caching: This technique caches a user control to store a
portion of a Web form response in memory.
9. What is Query String in ASP? And what are its advantages
and disadvantages?
A QueryString is a string of characters entered into a web browser on a computer. It
comes in handy when we need to move a value from one page to another. We can't
use Request if we're sending a significant amount of data. Since it only supports 255
characters, it's called QueryString. To separate numerous query strings, we utilise
the '&' special character. The called ASPX page will have access to any query string
that was available to the calling ASPX page.
10. What does the method ‘Finalize’ do in ASP.NET?
Before the current object is destroyed, the Finalize technique is used to run a
cleanup procedure on unmanaged resources owned by the current object. The
strategy is guaranteed, and it is then available only through this class or a derived
class.
11. What are the steps in the ASP.NET page life cycle?
 Starting of page life cycle
 Page request
 Page Load
 Page initialization
 Postback event handling
 Validation
 Unload
 Page rendering
12. What is the web.config file?
The configuration file (web.config) is used to manage the various settings that
distinguish a website. The settings are stored in XML files which are different from
the code of your programme. This allows you to freely configure settings from your
code. This file is located in the root directory of the application.
13. Which compiler is used in ASP.NET?
To put together an ASP.NET programme, the Roslyn compiler was used by the NET
framework.
14. ASP.NET is open-source. Explain?
On the .NET (dotNET) platform, ASP.NET is an open-source web framework for
developing web applications. Microsoft released version 1.0 in 2002, allowing users
to create dynamic online applications, services, and websites. The framework is built
to interact with the HTTP convention, which is the most widely used protocol for web-
based applications. ASP.NET is the next version to the ASP (Active Server Pages)
technology, and it represents a substantial advancement in terms of adaptability and
capability. It's an add-on to the .NET framework that includes additional tools and
libraries for developing web-based apps and websites. ASP.NET Core is the cross-
plate form version of ASP.NET, which was released in 2016. The ASP.NET
framework is still being upgraded.
15. Explain the Global.asax file?
Global.asax is a file present in the application root directory that is optional. Session
Start, Session End, Application Start, Application End and other application events
are handled in this file. The ASP.NET application file is another name for it.
Global.asax contains a class which represents your entire application. This file is
compiled at runtime into a dynamically generated .NET class based on the HTTP
Application base class. This file can be sent as an assembly to an ASP.NET
application's bin catalogue. The Global.asax record is built in such a way that if a
user requests the document, it will be rejected. External users are unable to
download or view the code contained within it.
16. What all types of Server controls are supported by
ASP.NET?
In ASP.NET, there are four primary types of server-side controls:
 Web Server controls
 HTML server controls
 Validation controls
 User controls
17. What does “PostBack” mean in ASP.NET?
The process of presenting an ASP.NET page to the server for processing is known
as a PostBack. If the page's credentials need to be validated against other sources
(for example, utilising a database to confirm the username and password), PostBack
is used. This is something that a client machine will not be able to do, hence these
details must be 'uploaded back' on the server. As a result, we say that a postback
event occurs on the client side but is handled by code in a server-side of the
webpage.
18. Explain the difference between Web.config and
Machine.config file?
The following are some important differences between Web.config and
Machine.config:
Web.config Machine.config

Web.config, on the other hand, is The machine.config record is your framework's master
a file that stores configuration configuration document, containing several default options.
information in XML format and
is used to apply local settings to
a website.

the values in the Web.config file The parameters in the Machine.config file apply to all asp.net apps
only apply to that particular web on your server
application.

Each web application has its own each.NET Framework form has only one machine.config file.
web.config file, Web.config files
can also be found in directories
within a web application.

Web.config documents contain Machine.config files contain shared values shared by multiple
application-specific information, programmes on the server.
such as database connection
strings.

If you make changes to the If you make changes to the machine.config, you must restart the
web.config, the web application application.
will load them immediately.
Web.config is created When you install Visual Studio.Net, the machine.config document
automatically when you create is created automatically and is located in the
an ASP.Net web application c:windowsmicrosoft.netframeworkversionconfig folder.
project.

Web.config is a configuration Machine.config is the design configuration file for all IIS apps.
file for a specific application.

19. Write a step for Request Flow in ASP.NET MVC framework?


In ASP.NET MVC, the Request Flow sequence is as follows:

The initial request is received in this step. After that, route objects are added to the
Route table object in the Global.asax file.
 Routing: The second phase involves routing. The URL Routing Module is
used to handle the request after the application receives it from the client.
The Route Table is a table that directs URLs to handlers. A routing
system coordinates with a system that compares the request's URL to the
URL patterns stored in the Route Table. When a match is detected in the
pattern, the Routing engine sends the request to the corresponding
IRouteHandler. It returns a 404 HTTP status if the related URL is not
found in the routing database.
 MVC Handler: A RouteHandler that determines the HTTP handler that
will serve the request based on the RequestContext supplied.
 Controller: The controller decides which action method will be used in this
stage.
 ActionInvoker will identify which Action method needs to be executed
after the controller is instantiated. To pick an action method, utilise the
ActionNameSelectorAttribute and ActionMethodSelectorAttribute
methods. The action method takes user input, executes the result, and
returns a result type that may be viewed.
20. Explain the various modes for the Session state in
ASP.NET?
 Sessions are saved on a web server within the application's process. It
might be aspnet wp.exe or w3wp.exe, depending on the IIS version used.
 StateServer: The State Server windows administration service is used to
save sessions.
 SQLServer: The information from sessions is stored in the SQL Server
database.
 A custom session state provider is in charge of all session states.
21. Write down different return types of a controller action
method?
 View Result
 Javascript Result
 Redirect Result
 JSON Result
 Content Result
22. How to maintain sessions in MVC?
In MVC, we can keep sessions in three different ways:
 Temporary data: TempData in ASP.NET MVC is basically a dictionary
object derived from TempDataDictionary.
 Viewdata: ViewData maintains data when you move from controller to
view. It is also a dictionary object and derived from ViewDataDictionary.
 View bag: The ViewBag is a dynamic type property of ControllerBase
class which is the base class of all the controllers.
23. What is NuGet package manager?
Software developers don't write all of their programming from the ground up. They
rely on code libraries created by other programmers. Any modern development
platform must include a means for developers to obtain and use pre-built libraries,
commonly referred to as packages. The JavaScript ecosystem, for example,
includes NPM (Node Package Manager), which allows developers to identify and
use libraries created by other JavaScript developers.
NuGet is a package manager for .NET framework. It was created by Microsoft to
give users access to thousands of packages created by .NET developers. It also
allows you to share the code you've written with others.
A typical ASP.NET web application relies on a large number of open source NuGet
packages to run. Consider the case of Newtonsoft. Json is a widely used library for
working with JSON data.
24. What is the use of the Program class?
Our application's entry point is the Program.cs class. An ASP.NET programme
begins with a static void Main() function, just like a console application.
This class sets up the web server that will handle the requests. The host is in charge
of the application's initialization and lifespan management, as well as graceful
shutdown.
The host must set up a server and a request processing pipeline at the very least.
Logging, configuration, and dependency injection can all be set up by the host.
25. What is the use of the Startup class?
This class is responsible for two key components of your application: service
registration and the middleware pipeline.
Services are C# classes that provide additional functionality to your application and
are utilised by both the framework and your application. Logging, database, and
other similar applications are examples. These services must be registered in order
to be invoked while your app is running and when it is required.
The middleware pipeline is the order in which an HTTP request is processed by your
application
ConfigureServices() and Configure() are two methods in the Startup class(). The first
approach, as its name implies, registers all of the services that the application
requires. The middleware pipeline is configured using the second technique.
26. What is the use of the wwwroot folder?
Our web application's static files and built assets, such as JavaScript, CSS, and
pictures, are stored under the wwwroot folder. The only folder in the entire project
that is visible to the browser as it is wwwroot.

27. What is the use of the appsettings.json file?


Appsettings.json is a file that holds all of the application's settings, allowing you to
customise its functionality.
A sample appsettings.json file is shown below.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ConnectionStrings": {
"AppConnection": ""
},
"AWS": {
"Profile": "local-test-profile",
"Region": "us-west-2"
},
"AllowedHosts": "*"
}
28. What is IIS?
Internet Information Services (IIS) is an acronym for Internet Information Services.
Microsoft has created a strong web server. IIS is also used as a load balancer,
distributing incoming HTTP requests to other application servers for increased
dependability and scalability.
It can also operate as a reverse proxy, accepting a client's request, forwarding it to
an application server, and returning the response to the client. Your application's
security, dependability, and performance are all enhanced by using a reverse proxy.
IIS has the drawback of only running on Windows. It is, nevertheless, highly
configurable. You can tailor it to your application's exact requirements.
29. What is dependency injection?
Dependency injection is a design pattern that aids in the creation of loosely linked
software. ASP.NET makes considerable use of this pattern.
Dependency injection refers to the practise of giving the objects that an object
requires (its dependencies) in the function Object() { [native code] } of that object
rather than requiring the object to construct them.
Dependency injection lowers and, in many cases, eliminates needless dependencies
between objects that don't need to communicate with one another. It also aids
testing by mimicking or stumping out dependencies during execution.
30.How does dependency injection works in ASP.NET Core?
The built-in IoC (Inversion-of-Control) container in ASP.NET Core injects instances
of dependency classes. The IServiceProvider interface, which enables function
Object() { [native code] } injection, represents this container.
Services are the types (classes) that the container manages. We must first register
our services with the IoC container in the Startup class in order for the IoC container
to automatically inject them.
Framework and application services are the two types of services supported by
ASP.NET Core. ILoggerFactory, IApplicationBuilder, IHostingEnvironment, and other
core services are part of the ASP.NET Core framework. A developer, on the other
hand, creates application services (custom types or classes) particularly for the app.
31. What is a cookie?
The cookie is a little piece of data that is stored in the browser and persists between
requests and even sessions. Cookies are little text files that contain information
about the user. The cookies are stored on the user's computer by the browser. The
cookies are usually stored as key-value pairs in most browsers.
Write a cookie in ASP.NET Core:
Response.Cookies.Append(key, value);
Delete a cookie in ASP.NET Core:
Response.Cookies.Delete(somekey);
32. What is the difference between Hyperlink and LinkButton?
The Hyperlink control lacks the Click and Command events, whereas the LinkButton
control does, and these events can be handled in the Web page's code-behind file.
33. What are navigation controls?
Navigation controls make it simple to navigate through a Web application. These
controls organise all of the links in a hierarchical or drop-down structure, making
navigation in a Web application much easier.
34. What are Globalization and Localization?
The process of designing and building application that works across many cultures
or geographies is known as globalisation. To put it simpler way, globalisation is the
process of designing and developing an application so that it may be used by people
from many cultural backgrounds. Your application will be ready for foreign markets
thanks to globalisation.
 This procedure entails determining the culture and location that the
application must support.
 Creating features that cater to those cultures and locations.
 Writing code that works with all supported cultures and locations equally
well.
 Localization is the process of adapting your programme to a specific
culture or location. To put it another way, localization is the process of
modifying your application so that it operates according to the existing
culture or locality. Localization is the process of translating your
application's user interface into the current culture or locale.
35. What is a Resource File?
Resource files are provided by ASP.NET to implement globalisation and localization.
The resource file has the extension resx and is an XML file. The resx file contains a
key-value pair for each resource. We will create a separate resource file for each
culture that your programme has to support. WebResources.en.resx, for example, is
a resource file for the English language, while WebResources.hi.resx is a resource
file for Hindi.
36. What are Local Resources and Global Resources?
The following are the two types of resource files:
Local Resources: Local resources are specific to a particular web page and are
used to provide different language versions of the same web page. These are kept in
the App LocalResources directory.
Global Resources: Global resources are shared by all web pages and can be
accessed from anywhere in the web application. The App GlobalResources folder
contains these files.
37. What is Neutral Culture, Culture, and Language?
A culture which is associated with a language but not with a country or place is
known as a neutral culture. For instance, "en" stands for English and "in" stands for
Hindi. Language and the country or region make up culture. It is identified by a
culture code, which consists of two lowercase letters indicating the language and two
uppercase letters indicating the country or location, such as en-US for English in the
United States, en-GB for the United Kingdom, and so on. Any spoken language,
such as English (en), Hindi (hi), and German (de), is considered a language.
38. What are the built-in objects in ASP.NET?
The following are the major built-in objects:
 Application
 Session
 Context
 Request
 Response
 Server
 Trace
39. What do you mean by Role-based security?
Almost every business employs role-based security, which allocates certain
privileges to each role.
 A role is allocated to each user from the list.
 Role-based privileges limit a user's actions on the system and ensure that
a user can only do what he is authorised to do.
40. What is event bubbling?
Event bubbling occurs when a child control sends events to the parent. Data Grid,
Data List, and Repeater are server controls that can include other child controls.
41. What is the command used to verify the presence of
ASP.NET in the system?
We use the "dotnet" command to check the presence of ASP.NET in the system and
to check its version.
42. What are the core sections of the ASP.NET App page?
A server-side file with the.aspx extension is also known as an ASP.NET page. It's
modular in design and may be broken down into the following sections:
 Directives for the Pages
 Page Layout for the Code Section
43. What are page directives in ASP.NET App?
The page directives create the conditions in which the page will operate. The @Page
directive is used by the ASP.NET page parser and compiler to declare page-specific
characteristics. Page directives define how a page should be processed and what
assumptions should be made about it.
44. What is the response object in ASP.NET App?
In ASP.Net App, the Response object is used to communicate data back to the user.
The ASP.net specific code is added using the <% and %> markers.

You might also like