Q1. Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
Q2. What’s the difference between Response.Write() andResponse.Output.Write()?
Sol : Response.Output.Write() allows you to write formatted output.
Q3. What methods are fired during the page load?
Sol : Init() - when the page is instantiatedLoad() - when the page is loaded into server memoryPreRender() - the brief moment before the page is displayed to the user as HTMLUnload() - when page finishes loading.
Q4. When during the page processing cycle is ViewState available?
Sol : After the Init() and before the Page_Load(), or OnLoad() for a control
Q5. Where do you store the information about the user’s locale?
Sol :System.Web.UI.Page.Culture
Q6. True or False: To test a Web service you must create a Windows application or Web application to consume this service?
Sol : False, the web service comes with a test page and it provides HTTP-GET method to test.
Q7. What does the "EnableViewState" property do? Why would I want it on or off?
Sol :It allows the page to save the users input on a form across postbacks. It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser. When the page is posted back to the server the server control is recreated with the state stored in viewstate.
Q8. Difference B/W Web Farm and Web Garden
Sol : Technical Diffference
In a Web Garden...
1. You have to run aspnet_state.exe utility
2. Configure the Web application's stateConnection and mode sessionState attribute in the Web.Config file.
In a Web Farm...
1. Install the installSQLState.SQL utility
2. Set the sessionState element's mode in the application's web.config file
3. set the sqlConnectionString attribute in the application's web.config file.
Q9. How many types of trgers are there in Sql server
Sol. There are two types of Trigers in Sql server -
1. After Triggers
2. Insteadof Triggers
Q10. What is Application Domain ? Explain
Q11.What is Index in Sql Server?
Q12. Difference B/W Clustered and Non-Clustrered Indexes?
Q13. What are the different types of Session state management options available with ASP.NET?
Sol. ASP.NET provides In-Process and Out-of-Process state management. In-Process stores the session in memory on the web server. This requires the a "sticky-server" (or no load-balancing) so that the user is always reconnected to the same web server. Out-of-Process Session state management stores data in an external data source. The external data source may be either a SQL Server or a State Server service. Out-of-Process state management requires that all objects stored in session are serializable.
Q14. How to call a Javascript function on Server side Button Click?
Q15.What do you understand by Bubbled Event?
Sol. When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.
Q16. What is Caching?
Q17. How many Security mechanism available in .Net ?
Q18. Describe Page Life cycle in .Net?
Q19. What is Serialization? Types Of Serialization?
Q20. What is Web service and how it is different from Remoting?
Q21. What is Viewstate ?How can I encrypt Viewstate of a page?
Q22. What are Value types and Reference types ?
Sol . Value types directly contain their data are either allocated on the stack or allocated in-line in a structure.
Reference types store a reference to the value's memory address, and are allocated on the heap.Reference types can be self-describing types, pointer types, or interface types.
Variables that are value types each have their own copy of the data, and therefore operations on
one variable do not affect other variables. Variables that are reference types can refer to the same object; therefore, operations on one variable can affect the same object referred to by another variable.All types derive from the System.Object base type.
Q23. What is Pooling in Sql Server?
Q24. How can I imlement Security in IIS?
Q25. What is Url Re-Writing?
Q26. What do you understand by the term "Sql-Injections" ?
Sol. SQL injection is a technique used to take advantage of non-validated input vulnerabilities to pass SQL commands through a Web application for execution by a backend database.
Q27. Give us a query for third highest salaried employee in an organisation?
Q28. Which one is better Inline queries Or Stored procedure? How ?
Q29. Can I use multiple runat server Forms in a given Asp.Net Page?
Q30. What is Boxing and Unboxing?
Sol. Boxing permits any value type to be implicitly converted to type object or to any interface type implemented by value type.Boxing is process in which a object instances created and copying value types value 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
Q31. Which one is better Server.Transfer () or Response.Redirect() ?
Sol.
Response.Redirect: This tells the browser that the requested page can be found at a new location. The browser then initiates another request to the new page loading its contents in the browser. This results in two requests by the browser.
Server.Transfer: It transfers execution from the first page to the second page on the server. As far as the browser client is concerned, it made one request and the initial page is the one responding with content. The benefit of this approach is one less round trip to the server from the client browser. Also, any posted form variables and query string parameters are available to the second page as well.
Q32. How can I validate the HTML input in my web form?
Q33.What is an interface and what is an abstract class?
Sol. In an interface, all methods must be abstract (must not be defined). In an abstract class, some methods can be defined. In an interface, no accessibility modifiers are allowed, whereas it is allowed in abstract classes.
Q34. Session state vs. View state?
Sol. In some cases, using view state is not feasible. The alternative for view state is session state. Session state is employed under the following situations:
Large amounts of data - View state tends to increase the size of both the HTML page sent to the browser and the size of form posted back. Hence session state is used.
Secure data - Though the view state data is encoded and may be encrypted, it is better and secure if no sensitive data is sent to the client. Thus, session state is a more secure option.
Problems in serializing of objects into view state - View state is efficient for a small set of data. Other types like DataSet are slower and can generate a very large view state.
Q35.Can two different programming languages be mixed in a single ASPX file?
Sol. ASP.NET’s built-in parsers are used to remove code from ASPX files and create temporary files. Each parser understands only one language. Therefore mixing of languages in a single ASPX file is not possible.
Q36.Can the view state be encrypted?
Sol. The view state can be encrypted by setting EnableViewStateMac to true and either modifying the element in Machine.config to or by adding the above statement to Web.config.
Q37. Why do uploads fail while using an ASP.NET file upload control to upload large files?
Sol. ASP.NET limits the size of file uploads for security purposes. The default size is 4 MB. This can be changed by modifying the maxRequestLength attribute of Machine.configs element.
Q38. What’s a proxy of the server object in .NET Remoting?
Sol. It’s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.
Q39. What are remotable objects in .NET Remoting?
Sol. Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.
Q40.What are channels in .NET Remoting?
Sol. Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.
Q41 What security measures exist for .NET Remoting in System.Runtime.Remoting?
Sol. None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.
Q42. What is a formatter?
Sol. A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.
Q43. Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs?
Sol. Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.
Q44. What’s SingleCall activation mode used for?
Sol. If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode.
Q45 What’s Singleton activation mode?
Sol. A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime lease.
Q46. What is marshalling and what are different kinds of marshalling ?
Sol. Marshaling is used when an object is converted so that it can be sent across the network or across application domains.Unmarshaling creates an object from the marshaled data.There are two ways to do marshalling :-
v Marshal-by-value (MBV) :- In this the object is serialized into the channel, and a copy of the object is created on the other side of the network. The object to marshal is stored into a stream, and the stream is used to build a copy of the object on the other side with the unmarshalling sequence.
v Marshaling-by-reference (MBR):- Here it creates a proxy on the client that is used to communicate with the remote object. The marshaling sequence of a
remote object creates an ObjRef instance that itself can be serialized across the network.
Q47. What is a IL? Twist :- What is MSIL or CIL , What is JIT?
Sol. (IL)Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL(Common Intermediate Language). All .NET source code is compiled to IL. This IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.
Q48. What is a CLR?
Sol. Full form of CLR is Common Language Runtime and it forms the heart of the .NET framework.All Languages have runtime and its the responsibility of the runtime to take care of the code execution of the program.For example VC++ has MSCRT40.DLL,VB6 has MSVBVM60.DLL , Java has Java Virtual Machine etc. Similarly .NET has CLR.Following are the responsibilities of CLR
v Garbage Collection :- CLR automatically manages memory thus eliminating memory leakes. When objects are not referred GC automatically releases those
memory thus providing efficient memory management.
v Code Access Security :- CAS grants rights to program depending on the security configuration of the machine.Example the program has rights to edit or create a new file but the security configuration of machine does not allow the program to delete a file.CAS will take care that the code runs under the environment of machines security configuration.
v Code Verification :- This ensures proper code execution and type safety while the code runs.It prevents the source code to perform illegal operation such as
accessing invalid memory locations etc.
v IL( Intermediate language )-to-native translators and optimizer’s :- CLR uses JIT and compiles the IL code to machine code and then executes. CLR also
determines depending on platform what is optimized way of running the IL code.
Q49. What is a CTS?
Sol. In order that two language communicate smoothly CLR has CTS (Common Type System).Example in VB you have “Integer” and in C++ you have “long” these datatypes are not compatible so the interfacing between them is very complicated. In order that two different languages can communicate
Q50. What is a CLS(Common Language Specification)?
Sol. This is a subset of the CTS which all .NET languages are expected to support.It was always a dream of microsoft to unite all different languages in to one umbrella and CLS is one step towards that.Microsoft has defined CLS which are nothing but guidelines that language to follow so that it can communicate with other .NET languages in a seamless manner.
Q51. What is a Managed Code?
Sol. Managed code runs inside the environment of CLR i.e. .NET runtime.In short all IL are managed code.But if you are using some third party software example VB6 or VC++ component they are unmanaged code as .NET runtime (CLR) does not have control over the source code execution of the language.
Q52. What is Difference between NameSpace and Assembly?
Sol. Following are the differences between namespace and assembly :
v Assembly is physical grouping of logical units. Namespace logically groups classes.
v Namespace can span multiple assembly.
Q53. What is Manifest?
Sol. Assembly metadata is stored in Manifest.Manifest contains all the metadata needed to do the following things( See Figure Manifest View for more details) :
v Version of assembly
v Security identity
v Scope of the assembly
v resolve references to resources and classes.
v 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.
Q54. What is GAC ?Twist :- What are situations when you register .NET assembly in GAC ?
Sol. GAC (Global Assembly Cache) is used where shared .NET assembly reside.GAC is used in the following situations :-
v If the application has to be shared among several application.
v 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.
Note :- Registering .NET assembly in GAC can lead to the old problem of DLL hell.
Where COM version was stored in central registry.So GAC should be used when
absolutely necessary.
Q55. What is concept of strong names ? Twist :- How do we generate strong names or what is the process of generating strong names , What is use of SN.EXE , How do we apply strong names to assembly ? , How do you sign an assembly ?
Sol. Strong name is similar to GUID(It is supposed to be unique in space and time) in COM components.Strong Name is only needed when we need to deploy assembly in GAC.Strong Names helps GAC to differentiate between two versions.Strong names use public key cryptography (PKC) to ensure that no one can spoof it.PKC use public key and private key concept.
Q56. What is garbage collection?
Sol. Garbage collection is a CLR feature which automatically manages memory. Programmers forget to release the objects while coding ..... laziness ( Remember in VB6 where one of the good practices is to set object to nothing).CLR automatically releases objects when they are no longer
referenced and in use.CLR runs on non-deterministic to see the unused objects and cleans them. One side effect of this non-deterministic feature is that we cannot assume an object is destroyed when it goes out of the scope of a function. Therefore, we should not put code into a class destructor to release resources.
Q57. Can we force garbage collector to run ?
Sol. System.GC.Collect() forces garbage collector to run.This is not recommended but can be used if situations arises.
Q58. What is reflection?
Sol. All .NET assemblies have metadata information stored about the types defined in modules.This metadata information can be accessed by mechanism called as “Reflection”.System.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.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim Pobjtype As Type
Dim PobjObject As Object
Dim PobjButtons As New Windows.Forms.Button()
Pobjtype = PobjButtons.GetType()
For Each PobjObject In Pobjtype.GetMembers
LstDisplay.Items.Add(PobjObject.ToString())
Next
End Sub
End Class
Q59. What are different types of caching using cache object of ASP.NET?
Sol. You can use two types of output caching to cache information that is to be transmitted to
and displayed in a Web browser:
v Page Output Caching
Page output caching adds the response of page to cache object.Later when page is requested page is displayed from cache rather than creating the
page object and displaying it.Page output caching is good if the site is fairly static.
v Page Fragment Caching If parts of the page are changing, you can wrap the static sections as user
controls and cache the user controls using pagefragment caching.
Q60. How can you cache different version of same page using ASP.NET cache object ?
Sol. Output cache functionality is achieved by using “OutputCache” attribute on ASP.NET page header.Below is the syntax
v VaryByParam :- Caches different version depending on input parameters send through HTTP POST/GET.
v VaryByHeader:- Caches different version depending on the contents of the page header.
v VaryByCustom:-Lets you customize the way the cache handles page variations by declaring the attribute and overriding the GetVaryByCustomString handler.
v VaryByControl:-Caches different versions of a user control based on the value of properties of ASP objects in the control.
Q61. How will implement Page Fragment Caching ?
Sol. Page fragment caching involves the caching of a fragment of the page, rather than the entire page. When portions of the page need to be dynamically created for each user request this is best method as compared to page caching.You can wrap Web Forms user control and cache the control so that these portions of the page don’t need to be recreated each time.
Q62. Is Session_End event supported in all session modes ?
Sol . Session_End event occurs only in “Inproc mode”.”State Server” and “SQL SERVER” do not have Session_End event.