ASP.Net Interview Short Questions
ASP.Net Short Interview Questions
Differences between Server-side and Client-side code?
Server side code is executed at the server side on IIS in ASP.NET framework, while client side code is executed on the browser.
What’ is the sequence in which ASP.NET events are processed ? 1 Page_Init.
3 Control events
4 Page_Unload event.
Page_init event only occurs when first time the page is started, but Page_Load occurs in subsequent request of the page.
In which event are the controls fully loaded ?
Page_load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that viewstate is not fully loaded during this event.
How can we identify that the Page is PostBack ?
What is event bubbling ?
How do we assign page specific attributes ?
What is the use of @ Register directives ?
What’s the use of SmartNavigation property ?
What type of code (server or client) is found in a Code-Behind class?
How many ways can we maintain the state of a page?
2. Server side – application , cache, context, session, database
What is AppSetting Section in “Web.Config” file ?
Where is ViewState information stored ?
RangeValidator It checks if the value in validated control is in that specific range. Example TxtMobileNo should be ten digit length.
CompareValidator It checks that the value in controls should match the value in other control. Example compare password with confirm password in registration form.
RegularExpressionValidator When we want the control value should match with a specific regular expression. We use it in Email and website address format check in registration form.
CustomValidator It is used to define UserDefined validation.
ValidationSummary It displays summary of all current validation errors at one place on web forms.
How can you enable automatic paging in DataGrid ?
- Set the “AllowPaging” to true.
- In PageIndexChanged event set the current pageindex clicked.
“Web.config” files apply settings to each web application, while “Machine.config” file apply settings to all ASP.NET applications.
Following are the differences between namespace and assembly :
- Assembly is physical grouping of logical units. Namespace logically groups classes.
- Namespace can span multiple assembly.
We can convert the integer “i” using “i.ToString()” or “Convert.ToString” so what’s the difference. The basic difference between them is “Convert” function handles NULLS while “i.ToString()” does not it will throw a NULL reference exception error. So as good coding practice using “convert” is always safe.
What is difference between abstract classes and interfaces?
- Abstract classes can have concrete methods while interfaces have no methods implemented.
- Interfaces do not come in inheriting chain, while abstract classes come in inheritance.
What is a CLR?
Following are the responsibilities of CLR
- Garbage Collection
- Code Access Security
- Code Verification
An assembly consists of one or more files (dlls, exe’s, html files etc.), and represents a group of resources, type definitions, and implementations of those types. An assembly may also contain references to other assemblies. These resources, types and references are described in a block of data called a manifest. The manifest is part of the assembly, thus making the assembly self-describing.
An assembly is completely self-describing.An assembly contains metadata information, which is used by the CLR for everything from type checking and security to actually invoking the components methods. As all information is in the assembly itself, it is independent of registry. This is the basic advantage as compared to COM where the version was stored in registry
- NameSpace Logically group types, example System.Web.UI logically groups our UI related features.
- In Object Oriented world many times its possible that programmers will use the same class name.By qualifying NameSpace with classname this collision is able to be removed.
- Version of assembly
- Security identity
- Scope of the assembly
- Resolve references to resources and classes.
- The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a stand-alone PE file that contains only assembly manifest information.
What is GAC ?
- If the application has to be shared among several application.
- If the assembly has some special security requirements like only administrators can remove the assembly. If the assembly is private then a simple delete of assembly the assembly file will remove the assembly.
Reflection can be used to browse through the metadata information. Using reflection you can also dynamically invoke methods using System.Type.Invokemember. Below is sample source code if needed you can also get this code from CD provided, go to “Source code” folder in “Reflection Sample” folder.
In Microsoft .NET there are three types of JIT compilers:
- Pre-JIT :- Pre-JIT compiles complete source code into native code in a single compilation cycle. This is done at the time of deployment of the application.
- Econo-JIT :- Econo-JIT compiles only those methods that are called at runtime. However, these compiled methods are removed when they are not required.
- Normal-JIT :- Normal-JIT compiles only those methods that are called at runtime. These methods are compiled the first time they are called, and then they are stored in cache. When the same methods are called again, the compiled code from cache is used for execution.
Boxing permits any value type to be implicitly converted to type object or to any interface type implemented by value type. Boxing is a process in which object instances are created and copy values in to that instance. Unboxing is vice versa of boxing operation where the value is copied from the instance in to appropriate storage location. Below is sample code of boxing and unboxing where integer data type is converted in to object and then vice versa.
Dim x As Integer
Dim y As Object
x = 10
‘ boxing process
y = x
‘ unboxing process
x = y
Authentication is verifying the identity of a user and authorization is process where we check does this identity have access rights to the system. In short we can say the following authentication is the process of obtaining some sort of credentials from the users and using those credentials to verify the user’s identity. Authorization is the process of allowing an authenticated user access to resources. Authentication always proceed to Authorization; even if your application lets anonymous users connect and use the application, it still authenticates them as being anonymous.