asp.net interview questions and answers for freshers
In this Article today learn asp.net interview questions and answers for freshers. follow the
asp.net interview questions and answers for freshers.
1. IL Code
It is an intermediate language. It is partially compiled or half compiled code.
Code --> Compile --> Machine Language
2. Why IL is half compiled
During runtime compiler able to figure out the operating system, hardware configuration and compile an optimal code as per environment.
Code --> IL Code --> JIT --> Machine Language
3. JIT
Just in tiem compiler. It convert IL code into machine language code. Three types of JIT.
- Pre JIT
Compiles source code into native code in single compilation cycle.
- Econo JIT
Compiles those methods which are called at runtine and remove then when not in use.
- Normal JIT
Compiles only those methods which are called at runtime. They are compiled first time and then stored in cache when not in use.
4. CLR(Common Language Runtime)
- It takes care of code execution of program. It has following responsibilities:
- Garbage Collection -
Automatically manages the memory thus eliminating memory leakages. Release objects when not in use.
- Code Access Security -
Grants the right to program depending on the security configuration of the machine.
- Code Verification -
Insures code execution and type safety while code runs.
- CTS(Common Type System)
In order that two diff languages communicate smoothly CLR has CTS.
- CLS(Common Language Specification)
Guideline which language should follow so it can comminucate with other .NET languages.
5. Managed and Unmanaged Code
The code that runs under environment of CLR(.NET runtime) called managed code. Code written in other language which suppport .NET are unmanaged code.
6. Assembly
Assembly is unit of deployment like exe or dll. It consist of one or more files and represents group of resource, type definition & implementation of that types.
All Information of assembly descritbed in a file called manifest.
7. Types of assembly
- Private Assembly
Normally used by single application and stored in application directory.
- Shared Assembly
When assembly shared among several applications then it called shared assembly.
Generally shared assembly kept in Global Assembly Cache by which shared assembly accessible to all applications.
8. Namespace
It is logical grouping of class, structure and interface.
9. Diff Bet assembly & namespace
- Assembly is physical grouping of units whereas namespace logically groups the classes.
- Namespace can span multiple assemblies.
10. .NET remoting
Here you can make remote object call which resides on different application domain.
11. Web service
Webservice are business logic components which provides functionality via the internet using standard protocals such as HTTP.
12. SOAP(Simple Object Access Protocol)
It is simple solution for interaction of different application built in different languages and running on diff platform as it uses HTTP protocol and XML as its payload for sending and receiving messages.
13. WSDL(Web Service Description Language)
It is specification which defines XML grammer for describing web service.
14. State Management
While using any web application current value of all controls for current user in current session called state.
HTTP is stateless protocol.
Types:
- Client Side
- View state :
In general used for storing user data. When user want to store or maintain thier data temporarily afer a postback then view state is used. ASP.NET page contains a hidden field named _VIEWSTATE.
EnableViewState = True
- Control State :
Data associated with server controls is called control state.
- Hidden Fields :
Hidden fields used to store small amount of data on client side. It is invisible in browser.
- Cookies :
Cookie is the set of small text file stored in users hard drive using client browser. It is used for identify purpose contains session id, some navigations or postback request objects.
Limitation of the Cookies:
The size of cookies is limited to 4096 bytes.
A total of 20 cookies can be used in a single website.
Default timeout of cookie is 30 minutes.
- Temporary/Session Cookie : Valid for single session
- Persistant cookie : Valid for multiple session
- Query String :
Used to hold some info from one page and move it to different page.
- Server Side
- Application State :
You can create application level object like name/value pair and share it across all users.
You can declare application level variables in Global.asax.
- Session State :
Session objects are stored on server side. They are primarily used for storing user specific information like shopping cart, preferences and never transferred to client.
Modes of storing session
- InProc: store session state in memory of web server IIS
- Out Proc : store session state on external server
- State Server : Stored session state in separate process called ASP.NET state server
- SQL server: store state in SQL database.
- Custom : You need to specify custom storage provider
- Cache :
Cache object is instance of System.web.caching.cache class. Cache stored on server side and more scalable in nature.
Cache objects can have expiration polocies set on them and shared across the users.
15. Validation Control
user input must be validate before sending it across the different layers of application.
- Client side validations
- Server side validations
Examples
- RequireFieldValidation
- CompareValidator
- RangeValidator
- Regular Expression Validation
- CustomValidator
- ValidationSummary
16. Difference between Server.transfer and response.redirect
Response.redirect redirects request to new URL while server.transfer terminates the execution of current page ans start execution of new page.
17. Global.asax
It allows you to write code that runs in response to system level events such as application starting, session ending, application error without having that code on each and every page.
Methods in Global file
- Application_Start()
- Application_End()
- Session_Start()
- Session_End()
- Application_Error()
18. ASP.NET Page life cycle
Page request--page initialization--page load--validation--postback event handling--page rendering--unload
18. Page life cycle events in ASP.NET
PreInit--Init--InitComplete--Preload--Load--LoadComplete--Prerender--PrerenderComplete--SaveStateComplete--Unload
19. Types of Authontication
- None
No authentication
- Windows
It will use local windows user to authenticate & authorise resource
- Form
It will use cookie based authentication using username and password
- Passport
Based on passport website provided by Microsoft.
20. Localization:
Process of translating resources for a specific culture.
21. Globalization:
Process of designing applications that can adapt to different cultures.
22. Web.config
Configuration file used to manage various settings that used to define a website. Those settings are stored in XML file and are separated from your application code.
23. PostBack
postback happens when a user takes some action that sends information from page to server. It posts complete page back to the server to refresh the whole page.
IsPostBack property of the page object is used to check if the page is posted back or not.
24. AutoPostBack
When we want a control to postback automatically when an event is raised, we need to se AutoPostBack property to true.
25. Use of Response.output.Write()
We can write formatted output string.
26. In which event of page lifecycle view state is available
After Init() and before PageLaod()
27. What is base class of all web forms
Page class
28. Viewstate
Viewstate used to retain state of server side objects between page postback.
29. Where the viewstate stored after page postabck
Viewstate stored in hidden field on the page at client side. Viewstate is transported to the client and back to server. It is not stored on the server and any other external source
30. How long the items in viewstate exist
They exist for the life of current page.
31. How to add event handler
Using attribute property of server side control
btnSubmit.Attributes.Add("Mouseover","JavascriptCode();")
31. Caching
Technique used to increase performance by keeping frequently accesseddata or file in memoty.
32. Types of caching
Output caching
Fragment Caching
Data Caching
33. If we want to cache portion of the page instead of whole page?
We can use fragment caching as it caches the portion of page generated by the request
34. Can we have web applicationrunning without web.config
Yes
35. Is it possible to create web application with both webforms and MVC?
Yes. We can used MVC assembly reference in web forms application to create hybrid application.
36. Prevent browser from caching an ASPX page
Response.Cache.SetNoStore();
37. What is good practice to implement variables in aspx page?
Client side validations is the best ways as it reduces network traffic and saves server resources.
38. Can we have multiple web.config files in one application?
Yes
39. Difference between web config and machine config
Web config is specific to web application whereas machine.config specific to that machine/server.
There can be multiple web.config into an application but can have only one machine config file on a server.
40. Cross page posting
- When we click submit button on web page, page post the data to 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 button that causes the postback.
41. PermanentPostback
It performs permanent redirection from requested URL to specified URL.
42. Passport Authentication
First it will check for passport authentication cookie. If cookie not available then application redirects user to passport sign on page. Passport service authenticates used details then if it is valid then it saved authenticated cookie on client machine and then redirets user to requested page.
43. In which event controls are fully loaded?
Page Load Event
44. How can we force all validation controls to run?
Page.Validate();
45. Use of appsetting section in web.config?
User defined values and settings for whole application. Generally connectionString specified in it.
46. Components of ADO.NET
Dataset, DataReader, data adapter, command, connection.
47. Diff between ExecuteScalar & ExecuteNonQuery
ExecuteScalar returns ouotput value whereas ExecuteNonQuery does not return any value but number of rows affected by query.
ExecuteScalar used for fetching single value and ExecuteNonQuery used to execute insert and update.
48. HTML server controls in ASP.NET
We can specify the HTML control to act as server control by adding runat="server" attribute.
48. Parent class of all web server controls
System.Web.UI.Control class
49. Role based security
It assigns certain privileges to particular role.
50. Diff between hyperlink and linkbutton
Hyperlink does not have click and command events whereas linkbutton has those events which can be handled in code behind file.
51. Navigation controls
It helps to navigate in web application easily. These controls stores all links in hierarchical or dropdown structure.
Navigation controls : SiteMapPath, Menu, TreeView
52. Diff between user control and custom control
- User control build into .ascx file and custom controls are build in dll
- User controls can be only used with current application but custom controls can be used with number of applications
- User controls are language dependent and custom controls are language independent i.e. control created in C# can be used in VB.NET
- User controls can be added by VS toolbox but custom controls can be added to VS toolbox.
53. Diff bet Dispose & Finalize()
- Finalize method called by Garbage collector which helps us to make free unmanaged resource.
- Dispose method is handled by IDisposable interface to explicitly release unused resource.
54. Diff bet value and reference type
Value type directly stores data and is allocated to stack.
Reference type store reference to values memory address.
55. Which DLL is used for .NET runtime
Mscoree.dll
No comments:
Post a Comment