This question bank has been created as an electronic resource for all kinds of .NET enthusiasts: novices who need to know the nitty-gritty details for their upcoming interviews, or experts who desire to refresh their knowledge of the framework. This question bank has been split into a series of 4 parts containing 25 questions each, focusing on the following topics:
- ASP.NET Framework 1.0/1.1/2.0
- SQL Server 2000/2005
- Web Services
- What is an interface and what is an abstract class?
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.
- Session state vs. View state:
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.
- Can two different programming languages be mixed in a single ASPX file?
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.
- Is it possible to see the code that ASP.NET generates from an ASPX file?
By enabling debugging using a
<%@ Page Debug="true" %> directive in the ASPX file or a
<compilation debug="true"> statement in Web.config, the generated code can be viewed. The code is stored in a CS or VB file (usually in the \%SystemRoot%\Microsoft.NET\Framework\v1.0.nnnn\Temporary ASP.NET Files).
- 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.
- 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
- 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.
- Can the view state be encrypted?
The view state can be encrypted by setting
true and either modifying the
<machineKey> element in Machine.config to
<machineKey validation="3DES” /> or by adding the above statement to Web.config.
- When during the page processing cycle is ViewState available?
The view state is available after the
Init() and before the
Render() methods are called during Page load.
- Do 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.
- What namespaces are imported by default in ASPX files?
The following namespaces are imported by default. Other namespaces must be imported manually using
@ Import directives.
- What classes are needed to send e-mail from an ASP.NET application?
SmtpMail have to be used to send email from an ASP.NET application.
SmtpMail are classes defined in the .NET Framework Class Library's
- Why do some web service classes derive from System.Web.WebServices while others do not?
Those Web Service classes which employ objects like
User have to derive from
System.Web.WebServices. If it does not use these objects, it is not necessary to be derived from it.
- What are VSDISCO files?
VSDISCO files are DISCO files that enable dynamic discovery of Web Services. ASP.NET links the VSDISCO to a HTTP handler that scans the host directory and subdirectories for ASMX and DISCO files and returns a dynamically generated DISCO document. A client who requests a VSDISCO file gets back what appears to be a static DISCO document.
- 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.
- How do I create an ASPX page that periodically refreshes itself?
META tag can be used as a trigger to automatically refresh the page every n seconds:
<meta http-equiv="Refresh" content="nn">
- How do I initialize a TextBox whose TextMode is "password", with a password?
Text property cannot be used to assign a value to a password field. Instead, its
Value field can be used for that purpose.
<asp:TextBox Value="imbatman" TextMode="Password"
ID="Password" RunAt="server" />
- 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
- How can the focus be set to a specific control when a Web form loads?
This can be achieved by using client-side script:
The above code will set the focus to a
TextBox1 when the page loads.
- How does System.Web.UI.Page's IsPostBack property work?
IsPostBack checks to see whether the HTTP request is accompanied by postback data containing a
__EVENTTARGET parameter. If there are none, then it is not a postback.
- What is WSDL?
WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). (Source: www.w3.org)
- What is UDDI?
UDDI stands for Universal Description, Discovery, and Integration. It is like an "Yellow Pages" for Web Services. It is maintained by Microsoft, IBM, and Ariba, and is designed to provide detailed information regarding registered Web Services for all vendors. The UDDI can be queried for specific Web Services.
- Is it possible to generate the source code for an ASP.NET Web service from a WSDL?
The Wsdl.exe tool (.NET Framework SDK) can be used to generate source code for an ASP.NET web service with its WSDL link.
Example: wsdl /server http://api.google.com/GoogleSearch.wsdl.
- 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
- Describe the difference between inline and code behind.
Inline code is written along side the HTML in a page. Code-behind is code written in a separate file and referenced by the .aspx page.