Git Product home page Git Product logo

asp-net-interview-questions's Introduction

Top 49 ASP.NET interview questions and answers in 2021.

You can check all 49 ASP.NET interview questions here ๐Ÿ‘‰ https://devinterview.io/dev/aspnet-interview-questions


๐Ÿ”น 1. What is ViewData?

Answer:

Viewdata contains the key, value pairs as dictionary and this is derived from classโ€Šโ€”โ€Šโ€œViewDataDictionaryโ€œ. In action method we are setting the value for viewdata and in view the value will be fetched by typecasting.

Source:ย medium.comย  ย 


๐Ÿ”น 2. What is ASP.Net?

Answer:

It is a framework developed by Microsoft on which we can develop new generation web sites using web forms(aspx), MVC, HTML, Javascript, CSS etc. Its successor of Microsoft Active Server Pages(ASP). Currently there is ASP.NET 4.0, which is used to develop web sites. There are various page extensions provided by Microsoft that are being used for web site development. Eg: aspx, asmx, ascx, ashx, cs, vb, html, XML etc.

Source:ย guru99.comย  ย 


๐Ÿ”น 3. What is the difference between ASP.NET and ASP.NET MVC?

Answer:

ASP.NET, at its most basic level, provides a means for you to provide general HTML markup combined with server side "controls" within the event-driven programming model that can be leveraged with VB, C#, and so on. You define the page(s) of a site, drop in the controls, and provide the programmatic plumbing to make it all work.

ASP.NET MVC is an application framework based on the Model-View-Controller architectural pattern. This is what might be considered a "canned" framework for a specific way of implementing a web site, with a page acting as the "controller" and dispatching requests to the appropriate pages in the application. The idea is to "partition" the various elements of the application, eg business rules, presentation rules, and so on.

Think of the former as the "blank slate" for implementing a site architecture you've designed more or less from the ground up. MVC provides a mechanism for designing a site around a pre-determined "pattern" of application access, if that makes sense. There's more technical detail to it than that, to be sure, but that's the nickel tour for the purposes of the question.

Source:ย stackoverflow.comย  ย 


๐Ÿ”น 4. What is a postback?

Answer:

A postback originates from the client browser. Usually one of the controls on the page will be manipulated by the user (a button clicked or dropdown changed, etc), and this control will initiate a postback. The state of this control, plus all other controls on the page (known as the View State) is Posted Back to the web server.

Source:ย stackoverflow.comย  ย 


๐Ÿ”น 5. What exactly is an application pool? What is its purpose?

Answer:

Application pools allow you to isolate your applications from one another, even if they are running on the same server. This way, if there is an error in one app, it won't take down other applications.

Additionally, applications pools allow you to separate different apps which require different levels of security.

Source:ย stackoverflow.comย  ย 


๐Ÿ”น 6. Explain startup process in ASP.NET Core?

Answer:

Everything starts from Program.cs

public static void Main(string[] args)
{
    BuildWebHost(args).Run();
}

public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .Build();

CreateDefaultBuilder extension method will create a default configuration which will look first into appsettings.json files then will look for Environment variables and at the end, it will use command line arguments.

This part will also set up default logger sources (debug and console) and load the settings for logging from appsettings.json.

After theย CreateDefaultBuilder finishes, then Startup class is executed. First, the constructor code is executed. After that, services are added to DI container via AddServices method that lives in Startup class. After that, an order of middleware that will handle every incoming request is set up.

Source:ย codingblast.comย  ย 


๐Ÿ”น 7. What is ViewState?

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

Source:ย c-sharpcorner.comย  ย 


๐Ÿ”น 8. Can ASP.NET Core work with the .NET framework?

Answer:

Yes. This might surprise many, but ASP.NET Core works with .NET framework and this is officially supported by Microsoft.

ASP.NET Core works with:

  • .NET Core framework
  • .NET framework
Source:ย talkingdotnet.comย  ย 


๐Ÿ”น 9. What is ASP.NET Core?

Answer:

ASP.NET Core is a brand new cross-platform web framework built with .NET Core framework. It is not an update to existing ASP.NET framework. It is a complete rewrite of the ASP.NET framework. It works with both .NET Core and .NET Framework.

Main characterestics of ASP.NET Core:

  • DI Container which is quite simple and built-in. You can extend it with other popular DI containers
  • Built-in and extensible structured logging. You can redirect output to as many sources as you want (file, Azure, AWS, console)
  • Extensible strongly typed configuration, which can also be used to reload at run-time
  • Kestrel โ€“ new, cross-platform and super fast web server which can stand alone without IIS, Nginx or Apache
  • New, fully async pipeline. It is easily configured via middleware
  • ASP.NET All meta package which improves development speed, and enables you to reference all Microsoft packages for ASP.NET Core and it will deploy only those that are being used by your code
  • There is no web.config. We now use appsettings.json file in combination with other sources of configuration (command line args, environment variables, etc.)
  • There is no Global._asax โ€“ We have _Startup.cs which is used to set up Middleware and services for DI Container.
Source:ย talkingdotnet.comย  ย 


๐Ÿ”น 10. Talk about Logging in ASP.NET Core?

Answer:

Loggingย is built-in and you get access to structured logs from the ASP.NET Core host itself to your application. With tools likeย Serilog,ย you can extend your loggingย easilyย and save your logs to file, Azure, Amazon or any other output provider. You can configure verbosity and log levels via configuration (appsettings.json by default), and you can configure log levels by different categories.

Source:ย talkingdotnet.comย  ย 


๐Ÿ”น 11. How to configure your ASP.NET Core app?

Answer:

Another crucial part of ASP.NET Core Framework is Configuration. Also, it is part of Dependency Injection. Use it anywhere in your code with an option toย reload on changesย of configuration values from sources (appsettings.json, environment variables, command line arguments, etc.). It is also easy to override, extend and customize the Configuration. No more extensive configurations in web.config, the preferred way now is appsettings.json in combination with a mix of Environment variables and cmd-line args.

Source:ย talkingdotnet.comย  ย 


๐Ÿ”น 12. What is the meaning of Unobtrusive JavaScript?

Answer:

This is a general term that conveys a general philosophy, similar to the term REST (Representational State Transfer). Unobtrusive JavaScript doesnโ€™t intermix JavaScript code in your page markup.

Eg : Instead of using events like onclick and onsubmit, the unobtrusive JavaScript attaches to elements by their ID or class based on the HTML5 data- attributes.

Source:ย medium.comย  ย 


๐Ÿ”น 13. What are the sub types of ActionResult?

Answer:

ActionResult is used to represent the action method result. Below are the subtypes of ActionResult:

  • ViewResult
  • PartialViewResult
  • RedirectToRouteResult
  • RedirectResult
  • JavascriptResult
  • JSONResult
  • FileResult
  • HTTPStatusCodeResult
Source:ย medium.comย  ย 


๐Ÿ”น 14. How can we prevent browser from caching an ASPX page?

Answer:

We can SetNoStore on HttpCachePolicy object exposed by the Response object's Cache property:

Response.Cache.SetNoStore();
Response.Write(DateTime.Now.ToLongTimeString ());
Source:ย guru99.comย  ย 


๐Ÿ”น 15. What is new in ASP.NET Core 2, compared to ASP.NET Core 1?

Answer:

With ASP.NET Core 2 several new features came out:

  • Razor Pages
  • DbContext Pooling with Entity Framework Core 2
  • Simplified Application Host Configuration
  • Configuration is now part of DI and ready for the time server reaches Startup class
  • Simplified authentication model
  • dotnet new now restore NuGet packages automatically
  • New meta package โ€“ Microsoft.AspNetCore.All
Source:ย codingblast.comย  ย 


๐Ÿ”น 16. What is the difference between Server.Transfer and Response.Redirect?

Answer:

In Server.Transfer page processing transfers from one page to the other page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. The clients url history list or current url Server does not update in case of Server.Transfer.

Response.Redirect is used to redirect the user's browser to another page or site. It performs trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.

Source:ย guru99.comย  ย 


๐Ÿ”น 17. How long the items in ViewState exists?

Answer:

They exist for the life of the current page.

Source:ย guru99.comย  ย 


๐Ÿ”น 18. Explain JSON Binding?

Answer:

JavaScript Object Notation (JSON) binding support started from MVC3 onwards via the new JsonValueProviderFactory, which allows the action methods to accept and model-bind data in JSON format. This is useful in Ajax scenarios like client templates and data binding that need to post data back to the server.

Source:ย medium.comย  ย 


๐Ÿ”น 19. In which event of page cycle is the ViewState available?

Answer:

After the Init() and before the Page_Load().

Source:ย guru99.comย  ย 


๐Ÿ”น 20. What are the different types of caching?

Answer:

ASP.NET has 3 kinds of caching :

  1. Output Caching,
  2. Fragment Caching,
  3. Data Caching.
Source:ย guru99.comย  ย 


๐Ÿ”น 21. What exactly is the difference between .NET Core and ASP.NET Core?

Answer:

.NET Core is a runtime. It can execute applications that are built for it.

ASP.NET Core is a collection of libraries that form a Framework for building web applications. ASP.NET Core libraries can be used on both .NET Core and the "Full .NET Framework" (what has shipped with windows for many years).

Source:ย stackoverflow.comย  ย 


๐Ÿ”น 22. Explain usage of Dependency Injection in ASP.NET Core

Answer:

Dependency Injectionย comes as a part of ASP.NET Core Frameworkย and everything is built around it. When you want to use some tool and its services, you usually add the NuGet package and you use one of its extension methods to add the package to the ASP.NET Coreโ€™s DI container. You can extend the current DI with a container of your choice (AutoFac, StructureMap, CastleWindsor etc).

Source:ย talkingdotnet.comย  ย 


๐Ÿ”น 23. List the events in ASP.NET page life cycle

Answer:

1) Page_PreInit
2) Page_Init
3) Page_InitComplete
4) Page_PreLoad
5) Page_Load
6) Page_LoadComplete
7) Page_PreRender
8) Render

Source:ย guru99.comย  ย 


๐Ÿ”น 24. In which event are the controls fully loaded?

Answer:

Page load event.

Source:ย guru99.comย  ย 


๐Ÿ”น 25. What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?

Answer:

View state is a kind of hash map (or at least you can think of it that way) that ASP.NET uses to store all the temporary information about a page - like what options are currently chosen in each select box, what values are there in each text box, which panel are open, etc. You can also use it to store any arbitrary information.

The entire map is serialized and encoded and kept in a hidden variable (__VIEWSTATE form field) that's posted back to the server whenever you take any action on the page that requires a server round trip. This is how you can access the values on the controls from the server code. If you change any value in the server code, that change is made in the view state and sent back to the browser.

Just be careful about how much information you store in the view state, though... it can quickly become bloated and slow to transfer each time to the server and back.

It's not encrypted at all. Just base encoded, which easily reversible.

Source:ย stackoverflow.comย  ย 


๐Ÿ”น 26. Explain Middleware in ASP.NET Core?

Answer:

Middleware is actually sequential series of delegates (piece of code), that can either short-circuit or pass on the HTTP request to next delegate. These are known as middleware, a concept well known to people who worked with Node.js.

Piece of your middleware can do one of the following:

  • Handle an incoming HTTP request by generating an HTTP response (maybe your authentication or authorization middleware will stop the request early and immediately create response)
  • Process the incoming request, change it and pass it to the next middleware in the pipeline
  • Process the outgoing response, change it and pass it on to next middleware in the pipeline or directly to the ASP.NET Core web server
Source:ย talkingdotnet.comย  ย 


๐Ÿ”น 27. Where the viewstate is stored after the page postback?

Answer:

ViewState is stored in a hidden field on the page at client side. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source.

Source:ย guru99.comย  ย 


๐Ÿ”น 28. What are the different validators in ASP.NET?

Answer:

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.

Source:ย c-sharpcorner.comย  ย 


๐Ÿ”น 29. What is the difference between 'classic' and 'integrated' pipeline mode in IIS7?

Answer:

Classic mode (the only mode in IIS6 and below) is a mode where IIS only works with ISAPI extensions and ISAPI filters directly. In this mode, ASP.NET is not much different from PHP or other technologies for IIS. This separation of the IIS and ASP.NET request-processing models results in duplication of some processing steps, such as authentication and authorization.

Integrated mode, on the other hand, is a new mode in IIS7 where IIS pipeline is tightly integrated (i.e. is just the same) as ASP.NET request pipeline. ASP.NET can see every request it wants to and manipulate things along the way. In this mode, ASP.NET HttpModules basically have nearly as much power as an ISAPI filter would have had and ASP.NET HttpHandlers can have nearly equivalent capability as an ISAPI extension could have.

Source:ย stackoverflow.comย  ย 


๐Ÿ”น 30. What is the difference between <system.web> and <system.webServer>?

Answer:

The system.web section is for configuring IIS 6.0, while the system.webserver version is used to configure IIS 7.0. IIS 7.0 includes a new ASP.NET pipeline and some configuration differences, hence the extra config sections.

The former is for Classic Mode. The latter is for Integrated Pipeline Mode (available in IIS7+).

Source:ย stackoverflow.comย  ย 


๐Ÿ”น 31. What is an HttpHandler in ASP.NET? Why and how is it used?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 32. What is the difference between ASP.NET Core Web (.NET Core) vs ASP.NET Core Web (.NET Framework)?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 33. How we can force all the validation controls to run?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 34. What is Katana?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 35. What is HttpModule in ASP.Net?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 36. What are the different Session state management options available in ASP.NET?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 37. What are the different types of cookies in ASP.NET?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 38. What is RedirectPermanent in ASP.Net?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 39. Which type if caching will be used if we want to cache the portion of a page instead of whole page?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 40. What is the difference between web config and machine config?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 41. Is it possible to create web application with both webforms and mvc?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 42. What is the difference between Web Service and WCF Service?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 43. How to choose between ASP.NET 4.x and ASP.NET Core?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 44. What exactly is OWIN and what problems does it solve?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 45. What is the equivalent of WebForms in ASP.NET Core?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 46. Name some ASP.NET WebForms disadvantages over MVC?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 47. What is Cross Page Posting?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 48. Are static class instances unique to a request or a server in ASP.NET?

๐Ÿ‘‰๐Ÿผ Check all 49 answers


๐Ÿ”น 49. What is the difference between a web API and a web service?

๐Ÿ‘‰๐Ÿผ Check all 49 answers



Thanks ๐Ÿ™Œ for reading and good luck on your next tech interview!
Explore 3800+ dev interview question here ๐Ÿ‘‰ Devinterview.io

asp-net-interview-questions's People

Contributors

devinterview-io avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.