1.The Page loading process
Inetinfo.exe is Microsoft IIS server handling ASP.NET requests.When an ASP.NET request is received (.aspx file), the ISAPI filter aspnet_isapi.dll manages it by transferring the request to the worker process aspnet_wp.exe.
2.Methods fired during Page Load
Init() - when the page is instantiated
Load() - when the page is loaded into server
PreRender() - the brief moment before the page is loaded in the client browser as HTML
Unload() - When the page is loaded completely.
3.When is the ViewState available during the page processing cycle?
After the Init() and before the Page_Load() or OnLoad() of a control
4.What are Satellite Assemblies?
When we create an application targeting different cultures, we have to provide certatin information like gif files and text files. Those files are stored in resource files and is complied into Satellite assembly.
Suppose we need to develop application which supports multilingual use we can use resource files for each language. These files are compiled as satellite assembly. To create a satellite assembly we need to convert it into resource file with the tool 'resgen' (ResourceGenerator)
5.Bubbled event?
When we have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite difficult. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its subitems.
6.Suppose you want to trigger certain ASP.NET function MouseOver of a button. Where do we add the event handler?
Add an OnMouseOver attribute to the button.
Example: buttonname.Attributes.Add("onmouseover","someSampleCode();");
7.Data types that are supported by RangeValidator control
Integer, String, and Date.
8.Difference between Server-side and Client-side code
Server-side code executes on the server.
Client-side code executes in the client's browser.
9.Difference between Server.Transfer and Response.Redirect
Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little overhead on the server. Server.Transfer does not update the clients url history or the current url.
Response.Redirect is used to redirect the user's browser to another page or site. This 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.
10.Difference between an ADO.NET Dataset and ADO Recordset?
Differences are:
- A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
- A DataSet is designed to work without any continuing connection to the original data source
- Data in a DataSet is bulk-loaded, rather than being loaded on demand.
- There's no concept of cursor types in a DataSet.
- DataSets have no current record pointer You can use For Each loops to move through the data
- You can store many edits in a DataSet, and write them to the original data source in a single operation
- Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources
11.What is the Global.asax used for?
The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.
12.Explain Diffgram.
The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.
13.What is MSIL?
MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL. MSIL also allows the .NET Framework to JIT compile the assembly on the installed computer
14.Which method do you invoke on the DataAdapter control to load your generated dataset with data?
The Fill() method
15.Can you edit data in the Repeater control?
No, it just reads the information from its data source.
16.Two properties common in every validation control
ControlToValidate property and Text property
17.Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?
DataTextField property
18.Which control would you use if you needed to make sure the values in two different controls matched?
CompareValidator control
19.What is the transport protocol you use to call a Web service?
SOAP (Simple Object Access Protocol) is the preferred protocol.
20.What is ViewState?
ViewState allows the state of objects to be stored in a hidden field on the page. ViewState is transmitted to the client and back to the server, and is not stored on the server or any other external source. ViewState is used the retain the state of server-side objects between postabacks
21.What is the lifespan for items stored in ViewState?
Item stored in ViewState exist for the life of the current page. This includes postbacks.
22.What does the "EnableViewState" property do?
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.
23.What are the different types of Session state management options available with ASP.NET?
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.
24.Explain Namespace
Namespaces are logical groupings within a program. There may be multiple namespaces in a single application, grouped based on the identifiers use. The name of any given identifier must appear only once in its namespace
25.Types of Authentication supported by ASP.NET.
- Windows (default)
- Forms
- Passport
- None (Security disabled)
26.What is CLR?
Common Language Runtime (CLR) is a run-time environment that manages the execution of .NET code and provides services like memory management, debugging, security, etc. The CLR is also known as Virtual Execution System (VES).
27.What is CLI?
The CLI is a set of specifications for a runtime environment, including a common type system, base class library, and a machine-independent intermediate code known as the Common Intermediate Language (CIL).
28.Explain Assembly and Manifest.
An assembly is a collection of one or more files and one of them (DLL or EXE) contains a special metadata called Assembly Manifest. The manifest is stored as binary data and contains details like versioning requirements for the assembly, the author, security permissions, and list of files forming the assembly. An assembly is created whenever a DLL is built. The manifest can be viewed programmatically by making use of classes from the System.Reflection namespace. The tool Intermediate Language Disassembler (ILDASM) can be used for this purpose.
29.What is Shadow Copy?
Earlier, to replace a COM component on a live web server, it was necessary to stop the entire website, copy the new files and then restart the website. This is not feasible for the web servers that need to be always running. .NET components on the other hand can be overwritten at any time using a mechanism called Shadow Copy. It prevents the Portable Executable (PE) files like DLLs and EXEs from being locked. Whenever new versions of the PEs are released, they are automatically detected by the CLR and the changed components will be automatically loaded. They will be used to process all new requests not currently executing, while the older version still runs the currently executing requests. By bleeding out the older version, the update is completed.
30.What is DLL Hell?
DLL hell is the problem that occurs when an installation of a newer application might break or hinder other applications as newer DLLs are copied into the system and the older applications do not support or are not compatible with them. .NET overcomes this problem by supporting multiple versions of an assembly at any given time. This is also called side-by-side execution.
31.Explain Web Services
Web services are programmable business logic components that provide access to functionality through the Internet. Standard protocols like HTTP can be used to access them. Web services are based on the Simple Object Access Protocol (SOAP), which is an application of XML. Web services are given the .asmx extension.
32.What is Postback?
When an action occurs (like button click), the page containing all the controls within the <form> tag performs an HTTP POST, while having itself as the target URL. This is called Postback.
33.Enumerate the types of Directives
- @ Page directive
- @ Import directive
- @ Implements directive
- @ Register directive
- @ Assembly directive
- @ OutputCache directive
- @ Reference directive
34.List the ASP.NET validation controls?
- RequiredFieldValidator
- RangeValidator
- CompareValidator
- RegularExpressionValidator
- CustomValidator
- ValidationSummary
35.Can a custom .NET data type be used in a Web form?
This can be achieved by placing the DLL containing the custom data type in the application root's bin directory and ASP.NET will automatically load the DLL when the type is referenced
36.List the event handlers that can be included in Global.asax?
- Application start and end event handlers
- Session start and end event handlers
- Per-request event handlers
- Non-deterministic event handlers
37.Can the view state be protected from tampering?
This can be achieved by including an @ Page directive with an EnableViewStateMac="true" attribute in each ASPX file that has to be protected. Another way is to include the '<pages enableViewStateMac="true" />' statement in the Web.config file
38.Can the view state be encrypted?
The view state can be encrypted by setting EnableViewStateMac to true and either modifying the <machinekey> element in Machine.config to '<machineKey validation="3DES� /'> or by adding the above statement to Web.config.
39.Does Web controls support Cascading Style Sheets?
All Web controls inherit a property named CssClass from the base class System.Web.UI.WebControls.WebControl which can be used to control the properties of the web control.
40.What classes are needed to send e-mail from an ASP.NET application?
The classes MailMessage and SmtpMail have to be used to send email from an ASP.NET application. MailMessage and SmtpMail are classes defined in the .NET Framework Class Library's System.Web.Mail namespace.
41.How can files be uploaded to Web pages in ASP.NET?
This can be done by using the HtmlInputFile class to declare an instance of an <input type="file" runat="server"/> tag. Then, a byte[] can be declared to read in the data from the input file. This can then be sent to the server.
42.To refresh an ASPX page periodically
The following META tag can be used as a trigger to automatically refresh the page every 'n' seconds:
<meta http-equiv="Refresh" content="n">
43.Why does the control's PostedFile property always show null when using HtmlInputFile control to upload files to a Web server?
This occurs when an enctype="multipart/form-data" attribute is missing in the <form> tag.
44.Why do uploads fail while using an ASP.NET file upload control to upload large files?
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.config's <httpRuntime> element.
45.What are possible implementations of distributed applications in .NET?
.NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services
46.What are the consideration in deciding to use .NET Remoting or ASP.NET Web Services?
Remoting is a more efficient communication exchange when you can control both ends of the application involved in the communication process. Web Services provide an open-protocol-based exchange of informaion. Web Services are best when you need to communicate with an external organization or another (non .NET) technology
47.What's a proxy of the server object in .NET Remoting?
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.
48.What are remotable objects in .NET Remoting?
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.
49.What are channels in .NET Remoting?
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.
50.What security measures exist for .NET Remoting in System.Runtime.Remoting?
None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.
51.What is a formatter
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.
52.What's the difference between private and shared assembly?
Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.
53.Strong name?
A strong name includes the name of the assembly, version number, culture identity, and a public key token
Can we have two files with the same file name in GAC?
Yes, GAC is a very special folder, and while normally you would not be able to place two files with the same name into a Windows folder, GAC differentiates by version number as well, so it’s possible for MyApp.dll and MyApp.dll to co-exist in GAC if the first one is version 1.0.0.0 and the second one is 1.1.0.0. So let’s say I have an application that uses MyApp.dll assembly, version 1.0.0.0. There is a security bug in that assembly, and I publish the patch, issuing it under name MyApp.dll 1.1.0.0.
54.What is delay signing?
Delay signing allows us to to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development.
55.How do I tell the client applications that are already installed to start using this new MyApp.dll?
Use publisher policy.
To configure a publisher policy, use the publisher policy configuration file, which uses a format similar app .config file. But unlike the app .config file, a publisher policy file needs to be compiled into an assembly and placed in the GAC.
56.What do you know about __EVENTTARGET and __EVENTARGUMENT hidden fields?
When an aspx page is rendered in the browser, it generates __doPostBack script method for most of the server controls other than Button only server-control. This method accepts the above two mentioned arguments. When the client-side action causes page to post back to the server, then it passes the ID of the control through __EVENTTARGET field.
The server then knows the control, which initiated the action and checks for any additional information passed through __EVENTARGUMENT field. Finally, the server executes the event code associated with the control. ASP.Net developers often use __doPostBack script to explicitly post the page to the server.
57.What does the RowState property indicate?
RowState is a property of DataRow object and it describes the current state of the row at any given time. When a DataTable object is filled from database then RowState of each row in its rows collection is Unchanged. If you modify a row within the rows collection then RowState of that specific row has value Modified. If you delete a row then RowState of row has value Deleted.
If you add a row to the table then RowState of the row has value Added. The RowState remains into effect until AcceptChanges or RejectChanges method of a row is called. The RowState changes to Unchanged after the execution of these methods.
58.What is the difference between RowStateFilter and RowFilter property?
Both of these properties belong to DataView object. When RowStateFilter property is applied to DataView it filters rows from the rows collection of data table based on the state of the row. This way you can retrieve newly added rows to the DataTable object or modified rows within the DataTable or combine different RowState values to get to the rows collection.
When RowFilter property is applied to DataView it acts the same way WHERE clause in any SQL query. Therefore it filters rows from the rows collection of data table based on column values meeting selection criteria.
59.What's the difference between Response.Write() and Response.Output.Write()?
Response.Output.Write() allows us to write formatted output
Access Modifiers(C#)
| Declared accessibility |
Meaning |
| public |
Access is not restricted |
| protected |
Access is limited to the containing class or types derived from the containing class |
| internal |
Access is limited to the current assembly |
| protected internal |
Access is limited to the current assembly or types derived from the containing class |
| private |
Access is limited to the containing type |
60.Partial Classes and its advantages
It is possible to split the definition of a class or a struct, or an interface over two or more source files. Each source file contains a section of the class definition, and all parts are combined when the application is compiled.
There are several situations when splitting a class definition is desirable:
i) When working on huge projects, spreading a class over separate files allows multiple programmers to work on the same class simultaneously.
ii) When working with automatically generated source, code can be added to the class without having to recreate the source file. Visual Studio uses this approach when creating Win Forms, Web Service wrapper code, and so on. We can create code that uses these classes without having to edit the file created by Visual Studio
iii) We can use the Partial keyword to specify the given class as a partial class.All the partial classes must have the same accessibility, such as public, private etc.
61.Key differences between Struct and Class
Struct are Value type and will be stored on stack. On the other hand Class are Reference type and are stored on heap. Struct “do not support inheritance, while class supports inheritance. However struct can implement interface. Struct should be used when you want to use a small data structure, while Class is best choice for complex data structure.