X



Home>Tutorial>

Top 53 ASP.Net Interview Questions and Answers

Nuelson Penuel Monday, September 14, 2020 ASP.Net

1. What is ASP.Net? ASP.Net is a framework invented by Microsoft on which new generation web sites can be easily developed using web forms(aspx), MVC, HTML, Javascript, CSS etc. Its successor of Microsoft Active Server Pages(ASP). Currently there is ASP.NET 4.6 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. 2. In what way can you force all validation controls to run? By using Page.Validate() method, all validation controls are forced to run and perform validation process. 3. What is repeater control? And list all it templates. Repeater control is a server side control that is used to display list of repeated items. It has the following templates i. ItemTemplate ii. HeaderTemplate iii. FooterTemplate iv. AlternatingltemTemplate v. SeparatorTemplate 4. What are the major ASP.Net built-in objects? i. Application ii. Request iii. Response iv. Server v. Session vi. Context vii. Trace 5. What is the use of appSettings Section in web.config file? AppSetting section in theconfiguration file is a section that allows us to keep configurable and application wide settings (for e.g.: ConnectionString) that an application requires in order to perform the tasks properly. For example, in the following code snippet, the specified ConnectionString section is used throughout the project for database connection:
<configuration>
<appSettings>
<add key="ConnectionString" value="server=local; pwd=password; database=default" />
</appSettings>
</configuration>
6. List data types supported by RangeValidator? They are i. Integer ii. Double iii. String iv. Currency v. Date. 7. State the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control? HtmlInputCheckBoxcontrol support multiple items selection from items group While HtmlInputRadioButton controls permit only one selection at a time from group of items. 8. What are the namespaces necessary to create a localized application? i. System.Globalization ii. System.Resources 9. List and explain the different types of ASP.Net cookies? Session Cookie: It is a cookie that is stored on user's device for a single session until the browser is closed or user logout. Persistent Cookie: It is a cookie that is stored on a user's device with expiration date specified either as 3 days, a month, or never. See more about ASP.Net cookies here 10. What is the file extension of web service? Web services have file extension .asmx 11. List the components of ADO.NET that you know? The components of ADO.Net are i. Data Adaptor ii. Command iii Dataset iv. Data Reader v. Connection. 12. State the differences between ExecuteNonQuery and ExecuteScalar i. ExecuteNonQuery is used to return rows affected by a specified query and does not return value While ExecuteScalar is used to return output value ii. ExecuteNonQuery can be used to execute Insert and Update statements While ExecuteScalar is only used for fetching a single value 13. What's the use of Response.Output.Write()? It is used for writing formatted output. 14. In which event of page cycle is the ViewState available? After the Init() and before the Page_Load() events 15. What is the difference between Server.Transfer and Response.Redirect?
  1. Response.Redirect() do not reduce server request hence do not conserve server resources. While Server.Transfer() reduces the server request and conserves server resources. Response.Redirect() can be used to redirect the users to another web-page on the same server or external server. While Server.Transfer can also be used to redirect users to another web page but only on the same server.
  2. Response.Redirect always change the address bar from the current page to the destination page. While Server.Transfer keeps the address of the current web page and still transfer user to the destination page.
See more about Server.Transfer and Response.Redirect here 16. All Web Forms are inherited from a base class. Which is? Page class 17. List the different ASP.Net validators you know? i. Required field Validator ii. Range Validator iii. Compare Validator iv. Custom Validator v. Regular expression Validator vi. Summary Validator 18. What validator control would you recommend if two different controls value must match? Compare Validator control 19. What is ViewState? ViewState is a client side state management technique that can be used for preserving user information within the same page after a round-trip to server. See more on ViewState here 20. Where is the ViewState is stored after the page postback? ViewState is stored in a HiddenField on the page at client side. 21. How long does ViewState values exists? Through out the life existence of the page the ViewState is created 22. List the different ASP.Net Sessions state management options available? i. In-Process ii. Out-of-Process. iii. In-Process stores the session in memory on the web server. 23. How can you add an event handler to ASP.Net? By using the attributes property of server side control e.g btnSubmit.Attributes.Add("onMouseOver","ScriptCodeToExecute();") 24. What is Caching? Caching is a technique used to increase website performance by keeping frequently requested files in memory. In other words, the request for a cached file will be accessed from cache instead of actual location of that file. 25. List the different types of caching? There are 3 types of caching in ASP.Net i. Output Caching, ii. Fragment Caching, iii. Data Caching. 26. What caching would you used to cache just a portion of a 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="130" VaryByParam="CategoryID;SelectedID"%> 27. What are the different events in page life cycle? i. Page_PreInit ii. Page_Init iii. Page_InitComplete iv. Page_PreLoad v. Page_Load vi. Page_LoadComplete vii. Page_PreRender viii. Render 28. Can a web application run without web.Config file? Yes 29. Is it possible to create web application with both webforms and mvc? Yes. We have to include below mvc assembly references in the web forms application to create hybrid application. i. System.Web.Mvc ii. System.Web.Razor iii. System.ComponentModel.DataAnnotations 30. Can we add code files of different languages in App_Code folder? No. The code files must be in same language to be kept in App_code folder. 31. What is Protected Configuration? It is a feature used to secure Connection String information. 32. Write code to send e-mail from an ASP.NET application? MailMessage mailMess = new MailMessage (); mailMess.From = "abc@gmail.com"; mailMess.To = "xyz@gmail.com"; mailMess.Subject = "Test email"; mailMess.Body = "Hi This is a test mail."; SmtpMail.SmtpServer = "localhost"; SmtpMail.Send (mailMess); MailMessage and SmtpMail are classes defined System.Web.Mail namespace. 33. How can you prevent a browser from caching an .aspx page? By defining SetNoStore on HttpCachePolicy object exposed by the Response object's Cache property: VB.Net

Response.Cache.SetNoStore();
Response.Write (DateTime.Now.ToLongTimeString ());
C#.Net

Response.Cache.SetNoStore();
Response.Write (DateTime.Now.ToLongTimeString ());
34. What is the good practice to implement validations in aspx page? Client-side validation is the best way to validate data of a web page. It reduces the network traffic and saves server resources. 35. What are the event handlers that we can have in 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
36. Which protocol is used to call a Web service? HTTP Protocol 37. Can we have multiple web config files for an ASP.Net application? Yes 38. What is the difference between web.config and machine.config? i. Web.config file is specific to a web application While Machine.config is specific to a machine or server. ii. We can have multiple web.config files in an application where as we can have only one machine.config file on a server. 39. What is role based security? Role Based Security is used to implement security based on roles assigned to user groups in an 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. 40. What is Cross Page Posting? Cross Page posting is a technique used to post one page data to another page. 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. 41. How can we apply Themes to an asp.net application? We can specify the theme in web.config file. Below is the code example to apply theme:
<configuration>
<system.web>
<pages theme="Windows7" />
</system.web>
</configuration>
42. What is RedirectPermanent in ASP.Net? RedirectPermanent is used to perform permanent redirection from the requested URL to the destination URL. Once the redirection is done, it also returns 301 Moved Permanently responses. 43. What is MVC? MVC is a framework used to create web applications. The web application base builds on Model-View-Controller pattern which separates the application logic from UI, and the input and events from the user will be controlled by the Controller. 44. Explain the working principles of passport authentication First of all it checks passport authentication cookie. If the cookie is not available then the application redirects the user to Passport Sign on page. Passport service authenticates the user details on sign on page and if valid then stores the authenticated cookie on client machine and then redirect the user to requested page 45. What are the advantages of Passport authentication?
  • All the websites can be accessed using single login credentials. So no need to remember login credentials for each web site.
  • Users can maintain his/ her information in a single location.
46. What are the ASP.NET Security Controls? : Provides a standard login capability that allows the users to enter their credentials : Allows you to display the name of the logged-in user : Displays whether the user is authenticated or not : Provides various login views depending on the selected template : Email the users their lost password 47. How do you register JavaScript for webcontrols ?We can register javascript for controls using Attribtues.Add(scriptname,scripttext) method. 48. In which event are the controls fully loaded? Page load event 49. What is boxing and unboxing? Boxing is assigning a value type to reference type variable. Unboxing is reverse of boxing ie. Assigning reference type variable to value type variable. 50. What is the difference between strong typing and weak typing In strong typing, the data types of variable are checked at compile time. On the other hand, in case of weak typing the variable data types are checked at runtime. In case of strong typing, there is no chance of compilation error. Scripts use weak typing and hence issues arises at runtime. 51. What is a SubString in ASP.Net? Substring function is used to obtain a part of a specified string from a given expression or string. Learn more about Substring here 52. What is the use of String.Equals Method in ASP.Net The String.Equals() method can be used in place of the "=" when comparing one string against another. Get more details on String.Equals here 53. When is the Replace Method used in ASP.Net? The replace method is mostly used when you want to replace text in one string with some another text. Learn more about replace function here

| | Views(418)

See Demo | Download File


Add your comment. Indicate code using code tag


Words: 0 | Chars: 0 | Reading Duration: 0



Images Attachment




Emmason Integratded Services(2017-2024)
All Rights Reserved
Designed and Maintained By Emmason Integrated Services