Top 100 ASP.Net Interview Questions and Answers

Table of Contents

1. What exactly is ASP.Net?

It is a Microsoft framework that allows us to create new generation web sites using web forms/web form (aspx), MVC, HTML, Javascript, and CSS, among other things. It is Microsoft Active Server Pages’ successor (ASP). ASP.NET 4.0 is a web development framework that is currently in use.

Microsoft provides a number of page extensions that are used in the development of websites. For example, aspx, asmx, ascx, ashx, cs, vb, html, XML, and so on.

2. What is Response’s purpose? Output. Write()?

Response allows us to create formatted output.

Output.

Write().

3. When does the ViewState become available during a page cycle?

Before the Page Load() and after the Init().

4. What is the difference between Server.Transfer and Response. Redirect?

Server.Transfer

Transfer page processing allows you to move from one page to the next without having to go back to the client’s browser. This results in a faster response while putting a little less strain on the server. In the event of Server, the client’s url history list or current url Server does not update.

Response.Redirect

The term “redirect” refers to the process of directing a user’s browser to another page or website. It makes a return trip to the client, redirecting the client’s browser to the new page. The new address is reflected in the user’s browser history list.

ASP.Net Interview Questions - difference between Server.Transfer and Response. Redirect

5. All Web Forms are descended from which base class?

All web forms are descended from page class.

6. What are the different ASP.NET validators?

  • Validator for required fields
  • Validator for a Range
  • Validator for comparison
  • Validator that is unique to you
  • Validator for regular expressions
  • Validator Summary

7. What is ViewState?

ViewState is used to keep the state of server-side objects.

8. How does the view state work?

Between page postbacks

9. What happens to the viewstate after the page is reloaded?

On the client side, ViewState is saved in a hidden field on the page. ViewState is sent to the client and returned to the server, but it is not saved on the server or anywhere else.

10. How long have the ViewState items been in existence?

They are only present for the duration of the current page.

11. What are the different options for managing session state in ASP.NET?

In-Process

Out-of-Process

managing session state in ASP.NET

On the web server/web servers, In-Process saves the session in memory.

Out-of-Process Data is stored in an external server for session state management. A SQL Server or a State Server may be used as the external server. All session objects must be serializable for Out-of-Process state management.

12. What is the procedure for adding an event handler?

Using the server-side control’s Attributes property.

13. What is caching?

Caching is a performance-enhancing technique that keeps frequently accessed data or files in memory. 

14. How does caching work?

The request for a cached file/data will be accessed from the cache rather than the file’s actual location.

15. What are the various caching techniques?

There are three types of caching in ASP.NET:

Output caching, fragment caching, and data caching are all examples of caching.

16. If we only want to cache a portion of a page rather than the entire page, which type of caching will we use?

Caching of a portion of the page generated by a request is known as fragment caching. To do so, we can use the code below to create user controls:

<%@ OutputCache Duration=”120″ VaryByParam=”CategoryID;SelectedID”%>

17. Make a list of the events that occur during the page’s life cycle.

Given below are the list of events that occur during the page life cycle:

1) Page PreInit

2) Page Init

3) Page InitComplete

4) Page PreLoad is a page that loads before the rest of the page.

5) Page Load is a function that allows you to load a page.

See also  Top 100 Hive Interview Questions And Answers

6) Page LoadComplete Page LoadComplete Page LoadComplete Page

7) Page PreRender is a function that is used to render a page before it is rendered

8) Create a rendering that is a list of page life cycle.

18. Is it possible to run a web application without the web.Config file?

Yes

19. Is it possible to use both webforms and mvc to create a web application?

Yes. To create a hybrid application, we must include the following mvc assembly references in the web forms/web form application.

  • System.Web.Mvc
  • System.Web.Razor
  • System.ComponentModel.DataAnnotations
webforms

20. Can we put code files in the App Code folder that are in different languages?

No, the code files in the App code folder must all be in the same language.

Top ASP.NET Interview Questions and Answers

21. What is Protected Configuration?

It’s a security feature that protects connection string data.

22. Write code for an ASP.NET application to send email?

protected void Page_Load(object sender, EventArgs e)
{
	try
	{
		MailMessage mailMessage = new MailMessage();
		mailMessage.To.Add("[email protected]");
		mailMessage.From = new MailAddress("[email protected]");
		mailMessage.Subject = "ASP.NET e-mail test";
		mailMessage.Body = "Hello world,\n\nThis is an ASP.NET test e-mail!";
		SmtpClient smtpClient = new SmtpClient("smtp.your-isp.com");
		smtpClient.Send(mailMessage);
		Response.Write("E-mail sent!");
	}
	catch(Exception ex)
	{
		Response.Write("Could not send the e-mail - error: " + ex.Message);
	}
}

23. How can we prevent an ASPX page from being cached by the browser?

The HttpCachePolicy object exposed by the Response object’s Cache property can be set to NoStore: Response.Write (DateTime.Now.ToLongTimeString ()); Response.Cache.SetNoStore (); 

24. How should validations be implemented in an aspx page?

The best technique to validate data on a web page is to use client-side validation. It reduces network traffic while also conserving server resources.

25. What are the different types of event handlers that can be used in the Global.aspx file?

Application Start, Application End, Application AcquireRequestState, Application AuthenticateRequest, Application AuthorizeRequest, Application BeginRequest, Application Disposed, Application EndRequest, Application Error, Application PostRequestHandlerExecute, Application PreRequestHandlerExecute, Application PreSendRequestContent, Application PreSendRequestHeaders, Application PostRe

Session Start and Session End are two session events.

26. When calling a Web service, what protocol is used?

HTTP (Hypertext Transfer Protocol) 

27. Can an asp.net application have multiple web config files?

Yes.

28. What is the distinction between web and machine configuration?

Machine config is specific to a machine or server, whereas web config is specific to a web application. Multiple web config files can be included in an application, but a server can only have one machine config file.

29. What is role-based security and how does it work?

Role-based security is a method of implementing security in an organisation based on roles assigned to user groups.

Then, depending on their role in the organisation, we can grant or deny access to users. Administrators, Users, and Guests are just a few of the built-in groups in Windows.

AUTHORIZATION> authorization > allow roles=”Domain NameAdministrators” / >!— Allow Domain Administrators. !— Deny anyone else with deny users=”*” / >!— Deny anyone else with deny users=”*” / >!— Deny anyone else with deny users=”*” / > /authorization > /authorization > /authorization > /authorization > /authorization >

30. What is Cross-Page Posting and How Does It Work?

The data is posted to the same page when we click the submit button on a web page. Cross-page posting refers to the process of posting data to multiple pages. The POSTBACKURL property of the button that causes the postback can be set to achieve this. The PreviousPage’s Findcontrol method can be used to retrieve the posted values on the page to which the page has been posted.

31. How can Themes be used in an ASP.NET application?

The theme can be specified in the web.config file. The following is an example of theme code:

<configuration>
<system.web>
<pages theme="Windows7" />
</system.web>
</configuration>

Top ASP.NET Interview Questions and Answers 

32. In ASP.Net(asp net), what is RedirectPermanent?

RedirectPermanent redirects the user from the requested URL to the specified URL indefinitely. It also returns 301 Moved Permanently responses once the redirection is complete.

33. What is MVC (Model View Controller)?

MVC is a web application development framework. The web application is based on the Model-View-Controller pattern, which separates application logic from user interface, with the Controller controlling user input and events.

34. Describe how passport authentication works.

It checks the passport authentication cookie first. The application will redirect the user to the Passport Sign on page if the cookie is not available. Passport service verifies the user’s credentials on the sign-in page, and if they’re correct, it saves the authenticated cookie on the client machine before redirecting the user to the requested page.

35. What are the benefits of using a passport for authentication?

A single set of login credentials can be used to access all of the websites. As a result, there’s no need to keep track of login credentials for each website.

Users can keep all of their information in one place.

36. What are the security controls in ASP.NET?

asp:Login>: Provides a standard login capability that allows users to enter their credentials.

asp:LoginName>: Allows you to display the name of the logged-in user.

asp:LoginStatus>: Displays whether the user is authenticated or not.

asp:LoginView>: Provides various login views depending on the selected template.

37. What is the procedure for registering JavaScript for webcontrols? 

We can register javascript for controls using the <CONTROL -name>Attributes.Add(scriptname,scripttext) method.

38. When do the controls become fully loaded?

This is a page load event.

39. What is the difference between boxing and unboxing?

Assigning a value type to a reference type variable is known as boxing.

Unboxing is the opposite of boxing, in which a reference type variable is assigned to a value type variable.

40. Distinguish between strong and weak type

The data types of variables are checked at build time in strong typing. In the case of poor typing, however, the variable data types are checked at runtime. There is no probability of a compilation mistake when strong typing is used. Because scripts have poor typing, problems develop at runtime.

41.  How can we make all of the validation controls execute at the same time?

The Web Page.

To compel all validation controls to run and do validation, use the Validate() function.

Top ASP.NET Interview Questions and Answers 

42. Make a list of all the Repeater control’s templates.

ItemTemplate

SeparatorTemplate

HeaderTemplate

FooterTemplate

ItemTemplate

AlternatingltemTemplate

43. What are the main ASP.NET built-in objects?

Trace of an application’s request and response to a server’s session context

44. What does the web.config file’s appSettings Section do?

The web config file’s appSettings block sets the user-defined variables for the entire application.

The supplied ConnectionString section, for example, is utilised throughout the project for database connection in the following code snippet:

em>configuration> appSettings> add key="ConnectionString" value="server=local; pwd=password; database=default; database=default" /> /appSettings>/em>

45. What data types is the RangeValidator control compatible with?

Integer, Double, String, Currency, and Date are the data types supported by the RangeValidator control.

46. How does a HtmlInputCheckBox control vary from a HtmlInputRadioButton control?

Multiple item selection is permitted with HtmlInputCheckBoxcontrols, however we can only select one item from a set of items in HtmlInputRadioButton controls.

47. What namespaces are required for a localised application?

System.Globalization

System.Resources

48. In ASP.NET, what are the different sorts of cookies?

Session Cookie – Remains on the client machine for the duration of a single session, unless the user logs out.

Persistent Cookie – Resides on a user’s machine for a period specified for its expiry, such as 10 days, one month, and never.

49. What is the web service’s file extension?

The file extension.asmx is used for web services.

50. What are the ADO.NET components?

Dataset, Data Reader, Data Adaptor, Command, and Connection are the components of ADO.Net.

Top ASP.NET Interview Questions and Answers 

51. What is the difference between ExecuteScalar and ExecuteNonQuery?

difference between ExecuteScalar and ExecuteNonQuery

ExecuteScalar returns the output value, whereas ExecuteNonQuery returns the number of rows affected by the query instead of a value. ExecuteScalar fetches a single value, while ExecuteNonQuery executes Insert and Update instructions.

52.What is the meaning of View State?

View State is a technique for preserving the page’s and controls’ values between round trips. It’s a method for managing state at the page level. View State is enabled by default, and it serializes the data in every control on the page, whether or not it is utilised during a post-back.

A stateless web application is one that does not keep track of user input. That implies that each time we send a request to the server for a page, a new instance of the page is produced, and our page is lost immediately after the round trip.

53.What are the characteristics and benefits of View State?

View State Characteristics 

These are the most important characteristics of the view state.

After a post-back, the value of the Control is retained without the need of a session.

The value of the page’s Pages and Control Properties is saved here.

Creates a custom View State Provider that allows you to save View State Data in a SQL Server Database or another data store.

View State’s Benefits

Benefits of view state
  • Implementation is simple.
  • There are no server resources required: The View State is stored in a structure that loads with the page.
  • Security aspects have been improved: It can be encoded and compressed or implemented in Unicode.

54.In ASP.NET, what are cookies?

Cookies are a State Management Technique for storing control values after a post-back. Cookies can be used to keep user-specific information on the client’s computer, such as the last time the user visited your site. HTTP Cookies, Browser Cookies, Web Cookies, Session Cookies, and other terms are all used to refer to cookies.

Cookies are a tiny text file supplied by the web server and kept on the client’s system by the Web Browser. The HttpCookies Class is represented by a list of properties.

Domain: We may set the cookie’s domain using these attributes.

Expires: This attribute specifies the cookie’s expiration date.

HasKeys: Returns True if the cookies have a subkey.

Name: Contains the Key’s name.

Path: This field contains the Virtual Path that will be sent with the Cookies.

If the cookies are to be sent via a secure connection, only True is returned.

See also  Top 65 Apache Kafka Interview Questions And Answers

The value of the cookies is stored in this field.

Cookies are restricted.

The maximum size of a cookie is 4096 bytes.

A single website can have a maximum of 20 cookies.

55. What is the definition of an ASP.NET Web API framework?

ASP.NET Web API is only used to create backend web APIs that can be used by a variety of clients, including web, desktop, and mobile. In the RESTful (Representational State Transfer) architecture, it is the server component.

56. ASP.NET MVC or ASP.NET Web API which would be the best framework to utilise.

ASP.NET Web API is the way to go if you want to create a server component that can be used by a variety of clients. If the project is just intended to be utilised as a web application, however, ASP.NET(asp net) MVC is a better option.

57.What is the purpose of the web.config file?

The web.config file is critical since it includes the application’s configuration settings. It separates your configuration from your code, allowing you to quickly modify settings without affecting your code. It may also be possible to encrypt the setup parameters for further security.

58. In ASP.NET, which compiler is used?

The compiler used by the.NET Framework is called Roslyn.

59. ASP.NET is a free and open-source framework. Explain.

Microsoft has made the entire.NET server stack open source, which means it is available for download for free. This contains ASP.NET(asp net), the.NET compiler, the.NET Core Runtime, Framework, and Libraries, allowing developers to create applications with.NET on Windows, Mac, and Linux.

60. Explain the ASP.NET MVC framework’s request flow.

The request flow processes client requests and sends them to the server. The controller receives a request from the client. Controller performs its function by determining which model to utilise in order to fulfil the request further, then sending that model to view, which changes the model and renders an appropriate answer to the client.

Top ASP.NET Interview Questions and Answers 

61. In.NET, what is tracing?

Tracing in.net allows you to follow a page’s execution path, debug the application, and view diagnostic information while it’s running. Trace messages can be accessed and manipulated directly from the code, allowing for more precise control and the addition of additional information. ASP.NET(asp net) organises the tracing data into a set of tables.

62. In.NET, why do we use CheckBox?

The checkbox is used to collect multiple responses from the user. Users have the option of selecting multiple options from the list. It is set as a yes/no or true/false option in the code; when it is ticked, the value of the checkbox is true; otherwise, it is false.

63. With an example, explain the App Domain concept in ASP.NET.

In ASP.NET, an app domain, also known as an application domain, is a lightweight process with its own set of code, configuration, and data settings. It’s a logical barrier that prevents one application from interfering with or accessing the data of another.

App domains improve resource utilization by reducing the number of processes required to run different applications. ASP.NET, for example, is a runtime host that creates unique application domains for each user who visits a website. These can be created and configured for apps that need to isolate code or dynamically load extensions.

64.In ASP.NET, what does “PostBack” mean?

A PostBack occurs when a user performs an action (such as submitting a form) that sends data from the page to the server via the POST method for processing.

65.In ASP.NET, what is the view state?

During postback event handling, data is used to preserve page values and control values of Web Forms. On the client web page, data can be stored as hidden fields.

66.What’s the distinction between custom and user controls?

Custom controls, also known as DLLs, are compiled code. These can be easily added to the toolbox, allowing it to be used across multiple projects with a drag-and-drop method. These controls are comparatively difficult to implement.

User Controls (.ascx) are similar to pages (.aspx). These are relatively simple to create, but they are tightly coupled in terms of User Interface and code.

67.In ASP.NET, what does the method Finalize do?

The Finalize method is used to perform cleanup operations on an object’s unmanaged resources. It adds an object to the queue for finalisation. The garbage collector will then collect the object, which will be cleaned up.

68.Important features of tracing in.NET?

  • Using the debug statement, we can see the page and application’s execution path.
  • We can programmatically access and manipulate trace messages.
  • We can see the most recent data tracing.

69.What is the LoginStatus Control’s purpose?

The LoginStatus control is used to display Login/Logout links based on the current user’s login/authorization status. The Logout link will appear if the user has successfully logged in.

70.  What are the limitations of cookies?

  •  The maximum size of a cookie is 4096 bytes.
  • A single website can have a maximum of 20 cookies.

Top ASP.NET Interview Questions and Answers

71. List of data bind controls in ASP.NET?

  • Controlling the Repeater
  • Controlling DataGrids
  • GridView Control 
  • DetailsView 
  • FormView 
  • DataList Control 
  • GridView
  • ListBox 
  • DropDownList
  • CheckBoxList 
  • RadioButtonList
  • List of bullets, etc.

72. What is the purpose of the HTML server controls in ASP.NET?

HTML server controls manage state and server-side events automatically. These are HTML elements with the runat=server property. The HTML server control properties and output are identical to their HTML tag counterparts. When the ASP.NET programme is compiled, these controls are also compiled.

73. Explain the use of state management in ASP.NET in a few words. Include some examples.

HTTP is stateless, which means it doesn’t remember a user’s current state, such as previously visited websites, requests, or URLs. However, for some requests, we need to save the application state till the end, and ASP.NET provides two solutions for this:

Client-side state management/client side validation: the state information is directly saved on the client computer in this technique. When a user makes a request, the necessary data is sent back and forth to satisfy the request and response—for example, cookies and query string.

Server-side state management/server side validation: the state information is kept in user memory in this approach. On the server side, there are more secure domains than on the client side. Server-side state management includes In-Proc, State server, and SQL server, and includes application and session state.

74. Give some web control samples.

  • Calendar
  • Checkboxlist 
  • Buttons
  • DropDownList
  • RadioButtonList

75. What’s the difference between an application object and a session?

The distinction between a session and an application object is that an application object is shared by all users, but a session object is unique to each user. The data saved in the application object may be accessed by all of the application’s sessions. The key-value pair saves data in the application object.

The Session object holds session-specific information that is only viewable during the session. For each session of the application, ASP.NET generates a unique SessionId. SessionIDs are stored in the application’s configuration settings as either an HTTP cookie or a changed URL. SessionID values are saved in cookies by default.

76. What exactly is caching, and what are the advantages of doing so?

Caching is a method that enhances an application’s speed by keeping data in memory for quicker access. When an application accesses data from Cache (i.e. in-memory) rather than the original data store (maybe a database), speed is significantly improved. However, the advantages of caching are not limited to performance; it also enhances the scalability and availability of applications.

77. What are the different forms of authentication in ASP.NET?

In ASP.NET, there are three different forms of authentication:

Windows Authentication: This authentication technique leverages the built-in security capabilities of Windows to verify a user’s identity.

Forms Authentication: Authenticates against a customised list of users or users in a database with Forms Authentication.

Passport Authentication: Validates against the Microsoft Passport service, which is essentially a centralized authentication service.

78. What exactly is ASP.NET AJAX?

Microsoft has created ASP.NET AJAX, which is an application of AJAX capabilities. AJAX (Asynchronous JavaScript and XML) is an acronym for Asynchronous JavaScript and XML.

This is a cross-platform technique that lowers bandwidth between the client and the server while speeding up response times. ASP.NET AJAX is a set of ASP.NET extensions that includes reusable AJAX controls.

79.What is the REST architecture, exactly?

REST (Representational State Transfer) is an architectural style for developing applications that mandates the use of HTTP for communication calls rather than more complex mechanisms such as CORBA, RPC, or SOAP. The REST architectural style is defined by a few principles:

Everything, including files, images, videos, and web pages, is a resource.

A Unique Identifier is assigned to each Resource.

Use simple and consistent user interfaces.

Everything is done through the medium of representation (sending requests from a client to server and receiving responses from server to client).

Be stateless—each request should be treated as a separate entity.

80. Explain how ASP.NET is cross-platform.

ASP.NET applications can be created and run on a variety of platforms, including Windows, Linux, macOS, and Docker. As a result, it’s known as a cross-platform framework.

Top ASP.NET interview questions and answers

81. What exactly is Razor in ASP.NET?

Razor is a markup syntax for embedding server-side code (Visual Basic and C#) into web pages. While a web page is being written to the browser, the server-based code can create dynamic web content on the fly.

When a web page is requested, the server runs the server-side code before returning the page to the browser. The code can perform complex tasks, such as accessing databases, by running on the server.

Razor is a web application development framework based on ASP.NET. It has the same functionality as traditional ASP.NET markup, but it’s simpler to use and understand.

82. What is the Program class’s purpose?

Our application’s entry point is the Program.cs class. An ASP.NET application 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 lifetime management, as well as graceful shutdown.

See also  Top 80 Microservices Interview Questions and Answers

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.

83. What is the wwwroot folder used for?

Your web application’s static files and compiled assets, such as JavaScript, CSS, and images, are stored in the wwwroot folder. wwwroot is the only folder in the entire project that the browser can access directly.

84.What exactly is IIS?

Internet Information Services (IIS) is an acronym for Internet Information Services. Microsoft has created a powerful web server. IIS can also be used as a load balancer, distributing incoming HTTP requests to various application servers for increased reliability and scalability.

It can also act as a reverse proxy, accepting a client’s request, forwarding it to an application server, and then returning the response to the client. Your application’s security, reliability, and performance are all enhanced by using a reverse proxy.

IIS has the drawback of only running on Windows. It is, however, highly configurable. You can tailor it to your application’s specific requirements.

85. What exactly is a Kestrel?

Kestrel is a cross-platform, open-source web server for ASP.NET Core. In ASP.NET Core, Kestrel is included and enabled by default. When compared to IIS, it is extremely light.

Kestrel can be used as a web server that accepts requests over a network, including the Internet.

86. Is there a distinction between IIS and Kestrel? What’s the point of having two web servers?

IIS and Kestrel differ primarily in that Kestrel is a cross-platform server. It is compatible with Windows, Linux, and Mac, whereas IIS is only compatible with Windows.

Another significant distinction is that Kestrel is completely open-source, whereas IIS is closed-source and developed and maintained solely by Microsoft.

IIS is an old piece of software with a lot of baggage and bloat. Microsoft designed Kestrel from the ground up with high performance in mind. They built it from the ground up, allowing them to ignore legacy and compatibility issues and concentrate on speed and efficiency.

Kestrel, on the other hand, does not have all of the features of a full-fledged web server like IIS, Nginx, or Apache. As a result, we usually use it as an application server, with one of the servers listed above serving as a reverse proxy.

87.What is the definition of an action method?

An action method is a controller class method that has the following restrictions:

  • It has to be open to the public. Methods that are private or protected are not permitted.
  • It can’t possibly be overloaded.
  • It isn’t possible for it to be a static method.

In response to an HTTP request, an action method performs an action.

88. What are the different types of IActionResult implementations?

There are many different types of IActionResult in ASP.NET Core:

Creates an HTML view with ViewResult.

RedirectResult—Sends a 302 HTTP redirect response to automatically redirect a user to a specified URL.

Sends a 302 HTTP redirect response to automatically redirect a user to another page, where the URL is defined using routing.

FileResult—As a response, this method returns a file.

ContentResult—As a response, this method returns a string.

StatusCodeResult—Sends a raw HTTP status code as a response, along with any associated response body content, if available.

NotFoundResult—Sends the response as a raw 404 HTTP status code.

89. What are the types of template fields does the Repeater Control have?

  • Item Template
  • AlternatingItem Template
  • Header Template
  • Footer Template
  • Separator Template

ASP.NET interview questions and answers

90.  What is ASP.NET Core, exactly?

The open-source and cross-platform version of ASP.NET is called ASP.NET Core. Prior to the release of ASP.NET Core, the Windows-only versions of ASP.NET were simply referred to as ASP.NET.

91. What is dependency injection?

Dependency injection is a design pattern that aids in the creation of loosely coupled software. ASP.NET makes extensive use of this pattern.

92. Explain the use of Global.asax in a few words.

Without having to add special, redundant code to each and every page on a website, Global.asax allows us to write code that responds to “system level” events like starting up the app, ending a session, or errors. In Visual Studio, we use it by going to Add > New Item > Global Application Class.

93. List a variety of ASP.NET validators.

  • Range Validator
  • Required Field Validator 
  • Regular Expression Validator 
  • Custom Validator 
  • Summary Validator

94. Is it possible to create a web app that uses both MVC and Web Forms?

By including assembly references in the Web Forms app, we can use both methods to create pages.

95. Mention the list of Hiring Tools for Top Developers

Here are a few tools to help you find top talent for your development needs that go beyond simply asking the right questions.

For hiring developers, Devskiller offers software-based real-world IT tests. It’s adaptable, so it can work for any job opening.

Goodcore is an ASP.NET-based job board.

Upwork has compiled a list of the top ASP.NET developers looking for work right now.

Toptal is a freelance developer marketplace that features the top 3% of programmers with experience in a variety of programming languages.

96. How does dependency injection work?

Dependency injection refers to the practise of providing 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 reduces and, in many cases, eliminates unnecessary dependencies between objects that don’t need to communicate with one another. It also aids testing by mocking or stumping out dependencies during execution.

97. Briefly describe the ASP.NET page life cycle. 

In the life cycle of each page, ASP.NET goes through a series of stages. According to Microsoft:

Request for a page. A page is requested by the user. ASP.NET determines whether it should be compiled or served from a cache.

Start. The conditions for the page’s start have been established.

Initialization. Themes are applied and on-page controls become available.

Load. The control properties are set by ASP.NET using the view state and control state properties.

Handling of postback events. User input is taken into account when it is available.

Rendering. ASP.NET saves the page’s view state and writes the rendering output to the output stream.

Unload. The client receives the rendered page. ASP.NET cleans up page properties and unloads them.

98. What are some of the advantages of ASP.NET Core over traditional ASP.NET?

Cross-Platform: ASP.NET Core differs from the legacy ASP.NET framework in that it is not restricted to the Windows operating system. On Linux or a Mac, you can create and run production-ready ASP.NET Core applications. Because you don’t have to pay for Windows licences when you use an open-source operating system like Linux, you can save a lot of money.

High Performance: It was also built from the ground up with performance in mind. It’s now one of the fastest frameworks for web applications.

Finally, it is open-source, with thousands of developers from around the world actively contributing. Everyone can see, change, and contribute back to the source code, which is hosted on GitHub. Despite the patches, bug fixes, and improvements added to the framework by contributors all over the world, it has resulted in significant goodwill and trust for Microsoft.

In addition to the traditional Model-View-Controller approach, ASP.NET Core allows you to develop applications using new technologies such as Razor Pages and Blazor.

99. What is the MVC pattern, and how does it work?

The Model-View-Controller (MVC) architectural pattern divides an application into three logical components: model, view, and controller. It’s worth noting that this pattern has nothing to do with the layered pattern we saw earlier. The MVC pattern is concerned with the software, whereas the layered pattern is concerned with the placement of our database and application servers.

Each component in an application that follows the MVC pattern has a well-defined role. Model classes, for example, only contain data and business logic. HTTP requests are not handled by them. Views are only used to display data.

The controllers are in charge of handling and responding to user input, as well as determining which model to pass to which view. This is referred to as responsibility separation. It makes it simple to develop and maintain an application as it grows in complexity.

Despite the fact that Model-View-Controller is one of the oldest and most well-known patterns, others have emerged over time. MVVM (Model-View-ViewModel), MVP (Model-View-Presenter), and MVA are some of the most popular patterns (Model-View-Adapter).

100. What is the NuGet package manager, and how does it work?

Software developers don’t write all of their code from the ground up. They rely on code libraries created by other programmers. Any modern development platform must include a mechanism for developers to download and use pre-built libraries, commonly referred to as packages.

The JavaScript ecosystem, for example, includes NPM (Node Package Manager), which allows developers to find and use libraries created by other JavaScript developers.

NuGet is a package manager for the Microsoft.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 popular package for working with JSON data in.NET (it has 91,528,205 downloads as of this writing).

Recommended Articles