LATEST ASP.NET Interview Questions & Answers 2020 | Freshers

LATEST ASP.NET Interview Questions & Answers | Freshers

Last updated on 11th Jun 2020, Blog, Interview Questions

About author

Suresh (Sr Technical Project Manager )

Highly Expertise in Respective Industry Domain with 10+ Years of Experience Also, He is a Technical Blog Writer for Past 4 Years to Renders A Kind Of Informative Knowledge for JOB Seeker

(5.0) | 16547 Ratings 1243

ASP.NET is an open-source, server-side web-application framework designed for web development to produce dynamic web pages. It was developed by Microsoft to allow programmers to build dynamic web sites, applications and services.An ASP.NET page is made up of a number of server controls along with HTML controls, text, and images. 

1. What is mvc ?


Mvc is an architectural design pattern, It is a Three tier architecture.  It consists of a model,view,controller.

2. What is a controller?


It is responsible for taking the end user request and loading the appropriate model and view.

3. What is the view?


View is responsible for look and feel.Most often view are created from the model data.

4. What is a model ?


Model represents the real world object and provides data to view. often model object retrieve data from the database.

5. What are the advantages of using MVC ?


Separation of concerns is achieved as we are moving the code behind to a separate file. Writing unit test for Automate manual testing. Lightweight Applications can be built.

6. What is routing ?


Routing helps you to define a URL structure and map the url with the controller.

7. Explain attribute based routing in mvc ?


This is a new feature in mvc 5. By using the “Route” attribute we can define the url structure.

8. How to maintain sessions in mvc ?


It can be done in three ways 

  • Tempdata
  • viewdata
  • viewbag.

9. What is viewdata ?


It helps to maintain data when moved from controller to view.

10. What is tempdata ?


It helps to send data from one controller to another controller or from one action to another action.It internally uses session variables .

11. Explain startup process in ASP.NET Core?


  • 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.

12. What is the use of keep and peek in “Tempdata” ?


Once TEMPDATA is read in the current request  it is not available in the subsequent request. Available in subsequent requests  then after reading  we need to keep the method.

13. What are partial views ?


Partial view is reusable views  which can be embedded inside another view.

14. Can we display all errors in one time ?


Yes, when can use the validation Summary method from the html helpers class.

15. What is razor in MVC  ?


It’s a lightweight view engine .its introduced in mvc 3.Syntaxes are very easy compared to .aspx view engine.

16. What are the different types of results in mvc ?


There 12 types of results some of the important for the interviews are

  • action results
  • view results
  • json Results.

17. Difference between Action Results and View results ?


Action results are abstract class  while view results are derived from action results.Action results  can be used to exploit polymorphism and dynamism

18. What is the appSettings Section in the web.config file?


The appSettings block in the web config file sets the user-defined values for the whole application.

For example, in the following code snippet, the specified ConnectionString section is used throughout the project for database connection:

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

19. What are Html helpers ?


This is used to modify HTML.But HTML helpers are more lightweight than HTML. Unlike web form controls,an html helper does not have  an event model  and a view state.

20. What are the main razor syntax rules ?


  • Razor code block are enclosed in @ { }
  • Code statement end with semicolon
  • Code is case sensitive
  • C# files have an extension .cshtml

    Subscribe For Free Demo

    21. Explain Areas in mvc ?


    Areas  are just a way to divide  or “isolate” the models of larger applications in a multiple or separated mvc.when you add an area to a project,a route for the area is defined in the Area Registration file.

    22. What are the advantages of Area?


    • Allows us to organize models, view, controller  in to  separate functional section of application
    • Easy to integrate with other area
    • Easy for unit testing

    23. Explain Scaffolding?


    You add scaffolding to your project when you want to quickly add code that interacts with models. It can reduce the amount of time.

    24. What is output caching ?


    It improves the performance of the application. It enables us to cache the content returned by the controller method so that the same  content does not need to be generated each time.

    25. Explain Bundling ?


    It lets us combine multiple js files or multiple .css files so that they can be downloaded as a unit, rather than making individual HTTP  requests.

    26. Explain Minification ?


    It squeezes out whitespaces  and performs other types of compression  to make the downloaded files as small as possible.

    27. What is a validation summary ?


    It is used to display  all the error messages for all the fields.It can also be used to display custom error messages.

    28. What is viewStart?


    Razor introduces a new layout named _viewstart which is applied to all views automatically. Razor view engine firstly executes the _viewStart and then starts rendering  the other view.

    29. How can we handle the custom error page ?


    Handle error attributes  allow us to use a custom error page for this error.Config file to allow your application to handle custom errors.

    30. Explain Json binding ?


    JavaScript object notation(JSON. binding support  started from MVC3 which allows  the action methods to accept and model-bind data in json format.

    Course Curriculum

    Learn ASP Dot Net Training with Industry Standard Concepts By MNC Experts

    • Instructor-led Sessions
    • Real-life Case Studies
    • Assignments
    Explore Curriculum

    31. Explain dependency resolution?


    This turn to be easier and useful for decoupling the application component and making it easier to test and configurable. It greatly simplified the use of dependency injection in your application.

    32. What are Ajax helpers?


    It is used to create AJAX enabled elements  like AJAX enabled forms and links which perform the request asynchronously.

    33. What is Section ?


    Section is part of html which is used to be rendered in the layout page.

    34. Explain RenderBody ?


    Renderbody is like a content placeholder in webforms.This exists in the layout page and it will render in the child view.There will be only one Render body in view.

    35. What is Cross Page Posting?


    When we click the submit button on a web page, the page posts the data to the same page. The technique in which we post the data to different pages is called Cross Page posting. This can be achieved by setting POSTBACKURL property of the button that causes the postback. Findcontrol method of PreviousPage can be used to get the posted values on the page to which the page has been posted.

    36. What are data annotations ?


    Data annotations can be used for server side validations.

    37. Can a view be shared across the multiple controllers  ?


    yes we can  share a view across the multiple controllers.we can put the view in “shared” folder

    38. Explain role based security ?


    Role Based Security used to implement security based on roles assigned to user groups in the organization.

    Then we can allow or deny users based on their role in the organization. Windows defines several built-in groups, including Administrators, Users, and Guests.

    • <AUTHORIZATION>< authorization >
    • < allow roles=”Domain_Name\Administrators” / >   
    • < !– Allow Administrators in domain. — >
    • < deny users=”*”  / >                       
    • < !– Deny anyone else. — >
    • < /authorization >

    39. What is dependency Injection?


    It’s a design pattern and it is used to develop loosely coupled code. This greatly used in software projects. This reduces the coding in case of changes in project design.

    40. Explain Test driven development (TDD) ?


    TDD is a methodology which says, write your tests first before you write code.In TDD tests drive your application design and development cycles.

    41. What is Representational state transfer means (REST) ?


    REST is an architectural style which uses  HTTP Protocol Methods like GET, POST, PUT, DELETE to access the data. ASP.Net MVC works in this style.

    42. What are the event handlers that we can have in the Global.asax file?


    Application Events: 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_ReleaseRequestState, Application_ResolveRequestCache, Application_UpdateRequestCache

    Session Events: Session_Start,Session_End

    43. Is mvc Suitable for both  windows and web application ?


    MVC Architecture is suited for  web application than windows.For windows MVP is more applicable. If you are using WPF or Silverlight  MVVM is more suitable.

    44. What does ASP.NET MVC mean?


    ASP stands for Active Server Pages and .NET is the framework that is used for ASP. It was first released in the year 2002 in the month of January. ASP.NET MVC is one of the lightweight and highly tested frameworks. While MVC stands for three different components and they are Model, View, and Controller.

    45. What do the Model, View, and Controller mean?


    Model: It is used for representing the application data and also used as a business entity.

    Controller: This is the place where the request sent by the user is found and the responsibility of the controller is to redirect the specific view with the help of View(. method.

    View: MVC has a representation layer known as a view.

    46. What are the new features of version 4 of MVC which is also known as MVC4?


    Following are the new features of MVC4:

    • Bundling of the java scripts.
    • They provide templates for mobile.
    • There is a separate configuration for MVC routing, Bundle, Web API, etc.

    47. What are the steps involved in the page life cycle of MVC?


    Following are the steps involved in the page life cycle of MVC:

    • Initialization of the app.
    • Routing
    • Execution of the controller
    • Locating and representing the controller action
    • Initiating and rendering the view.

    48. What is the use of Response.Output.Write()?


    Response.Output.Write() is used for writing a formatted output.

    49. Where can we find ViewState?


    ViewState is found after the use of Init() and before the use of Page_Load().

    50. Name the different validators available in ASP.NET.


    Following are the different validators that are available in ASP.NET:

    • Range validator
    • Compare validator
    • Custom validator
    • Summary validator
    • Regular expression validator
    • Required field validator

    Course Curriculum

    Best ASP.NET Training Course & Get Noticed By Top Hiring Companies

    Weekday / Weekend BatchesSee Batch Details

    51. Name the base class through which Web Forms are inherited.


    Page class is used for getting all the WebForms.

    52. What is ViewState?


    ViewState is used for retaining the state of server-side objects that are between the page postbacks.

    53. What is the use of a Compare validator?


    Compare validator is used for making sure that the values in two different set controls are matched.

    54. Name the different session state that is available in ASP.NET.


    Following are the different session state that is available on ASP.NET:

    • In-Process
    • Out-of-Process

    55. What is In-process?


    In-Process is one of the session states that is available in the ASP.NET. It is used for storing the session in memory on the web server.

     56. What is Out-of-Process?


    Out-of-process is one of the session states that is available in the ASP.NET. It is used for storing the data in the external server which is either a State server or SQL server. For state management, all the sessions stored should be serialized.

    57. What does caching mean?


    Caching is defined as a technique that is used for increasing the performance by keeping frequently accessed files in memory. The access for the cached file is obtained through the cache and not from the actual location of the file.

    58. Name the different types of caching.


    Following are the different types of caching:

    • Output caching
    • Fragment caching
    • Data caching

    59. What is the use of Fragment caching?


    Fragment caching is used for caching a portion of a page instead of caching the entire page. Below is the code that is used for Fragment caching:

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

    60. Name the events in the page life cycle.


    Following are the events in the page life cycle:

    • Page_PerInit
    • Page_Init
    • Page_InitComplete
    • Page_PreLoad
    • Page_Load
    • Page_LoadComplete
    • Page_PreRender
    • Render

    61. What is the difference between the ASP and ASP.NET?


    The main difference between ASP and ASP.Net is that ASP is interpreted, while ASP.Net is compiled. ASP uses VBScript, therefore when the ASP page is executed, it is interpreted. On the other hand, ASP.Net uses .Net languages like C# and VB.NET, which is compiled to Microsoft intermediate language.

    62. Name the components of ADO.NET.


    Following are the components of ADo.NET:

    • Dataset
    • Data reader
    • Data adaptor
    • Command
    • Connection

    63. How can we prevent browsers from caching an ASPX page?


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

    • Response.Cache.SetNoStore ();
    • Response.Write (DateTime.Now.ToLongTimeString ());

    64. Name the different types of cookies in ASP.NET.


    Following are the two types of cookies on ASP.NET:

    • Session cookie
    • Persistent cookie

    65. What are session and persistent cookies?


    • Session cookie: Until and unless the user logs out, the session cookie resides on the client machine.
    • Persistent cookie: These cookies have a fixed duration like 10 days, a month’s duration, etc and expire once the duration gets over.

    66. Name the namespaces used for creating a localized application.


    Following are the two namespaces used for localized application:

    • Globalization
    • Resources

    67. Differentiate between HtmlInputCheckBox control and an HtmlInputRadioButton control.


    Following is the difference between HtmlInputCheckBox control and HtmlInputRadioButton control:

    • HtmlInputCheckBox control :  It is used for selecting multiple items
    • HtmlInputRadioButton control  :It is used for selecting a single item from the group of items

    68. What is the use of Range validator?


    Range validator control support is used for controlling integer, double, string, currency, and date. These are also the different types of data supported by Range validator.

    69. Name a few web service technologies.


    Following are web service technologies:

    • XML
    • SOAP
    • WSDL
    • UDDI

    70. Name the major built-in objects in ASP.NET.


    Following are the major built-in objects in ASP.NET:

    • Trace
    • Context
    • Session
    • Server
    • Response
    • Request
    • Application

    Asp Net Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

    71. Name the templates of Repeater control.


    Following are the templates of Repeater control:

    • Footer template
    • Header template
    • Item template
    • Alternating item template
    • Separator template

    72. Differentiate between strong typing and weak typing.


    Following is the table explaining the difference between strong typing and weak typing:

    • Strong typing :It is used for checking the data types of variables during the compilation time Compilation errors are nil
    • Weak typing : It is used for checking the data types of variables during the runtime As the scripts used are weak, there are chances of issues

    73. What is the use of Page.Validate() method?


    Page.Validate(. method is used for forcing and performing all the validation.

    74. Differentiate between boxing and unboxing.


    Following is a table explaining the difference between boxing and unboxing:

    • Boxing : It is used for assigning a value type for the reference type variable
    • Unboxing : It is used for assigning a reference type for the value type variable

    75. Name a few ASP.NET security controls.


    Following are the ASP.NET security controls:

    • <asp:Login>
    • <asp:LoginName>
    • <asp:LoginStatus>
    • <asp:PasswordRecovery>

    76. Name the event handlers in Global.asax file.


    Following are the two event handlers in Global.asax file:

    • Application events
    • Session events

    77. Name a few application events.


    Following are the application events:

    • Application_Start
    • Application_End
    • Application_Error
    • Application_ReuestCache
    • Application_EndReuest

    78. Name a few session events.


    Following are the session events:

    • Session_Start
    • Session_End

    79. What are the advantages of ASP.NET?


    Following are the advantages of ASP.NET:

    • HTML is separated from the code
    • Compiled languages are supported
    • Management of state
    • There is a scope for graphical development
    • .NET framework is used by the service

    80. Name the types of validation available in ASP.NET.


    Following are the two types of validation that are available on ASP.NET:

    • Client-side validation
    • Server-side validation

    81. What does Client-side validation mean?


    Client-side validation refers to the validation which is done on the client-server and JavaScript is used for validation.

    82. What does Server-side validation mean?


    Server-side validation refers to the validation which is done on the server. It is a secure validation.

    83. What are the features of ViewState?


    Following are the features of ViewState:

    • Without using session, the control value is retained even after performing post-back.
    • The page values and control properties are stored in ViewState.
    • ViewState information can be saved in the SQL server database.

    84. What are the advantages of ViewState?


    Following are the advantages of ViewState:

    • Implementation is easy.
    • There is no requirement of server resources.
    • Advanced features are used.

    85. Name the different types of state management available in ASP.NET.


    Following are the two types of state management available in ASP.NET:

    • Client-side state management
    • Server-side state management

    86. Name the client-side state management.


    Following are the client-side state management:

    • View state
    • Control state
    • Cookies
    • query strings
    • Hidden fields

    87. Name the server-side state management.


    Following are the server-side state management:

    • Profile properties
    • Session state
    • Application state

    88. Name the themes that are available in ASP.NET.


    Following are the two themes that are available on ASP.NET:

    • Page theme
    • Global theme

    89. What are the advantages of ASP.NET MVC?


    Following are the advantages of ASP.NET MVC:

    • Large applications can be divided into multiple areas making it easy for the management.
    • The support for Facebook and Google authentication is by default.
    • Languages like Javascript, CSS, and HTML have full control.
    • ViewState or server-based forms are not used.

    90. What are the properties of HttpCookies class?


    Following are the properties of HttpCookies class:

    • The domain of the cookie is set by using the domain
    • The expiration of the cookies are using expire
    • The values for the cookies are set using value
    • The names of the keys are fixed using the name

    91. What are the limitations of cookies?


    Following are the two limitations of cookies:

    • In a single website, the number of cookies used is 20.
    • 4096 bytes is the maximum limit of the size of the cookies used.

    92. What are the features of web service?


    Following are the features of web services:

    • It is language independent.
    • It is protocol independent.
    • It is platform-independent.
    • It is programmable.
    • It is a self-describing software program.

    93. What is a page directive in ASP.NET?


    Basically Page Directives are commands. These commands are used by the compiler when the page is compiled.

    94. What is ASP.NET Core?


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

    Main characteristics 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.

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


    • 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 a 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.

    96. What are the different validators in ASP.NET?


    • Required field Validator
    • Range Validator
    • Compare Validator
    • Custom Validator
    • Regular expression Validator
    • Summary Validato

    97. What are the different Session state management options available in ASP.NET?


    • In-Process
    • Out-of-Process.

    In-Process stores the session in memory on the web server.

    Out-of-Process Session state management stores data in an external server. The external server may be either a SQL Server or a State Server. All objects stored in session are required to be serializable for Out-of-Process state management

    98. How can you add an event handler?


    Using the Attributes property of server side control.


    • btnSubmit.Attributes.Add(“onMouseOver”,”JavascriptCode();”)

    99. Which type of caching will be used if we want to cache the portion of a page instead of the whole page?


    Fragment Caching: It caches the portion of the page generated by the request. For that, we can create user controls with the below code:

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

    100. Write code to send email from an ASP.NET application?


    MailMessage and SmtpMail are classes defined System.Web.Mail namespace.

    • MailMessage mailMess = new MailMessage ();
    • mailMess.From = “”;
    • mailMess.To = “”;
    • mailMess.Subject = “Test email”;
    • mailMess.Body = “Hi This is a test mail.”;
    • SmtpMail.SmtpServer = “localhost”;
    • SmtpMail.Send (mailMess);

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free