Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

100 ASP.NET FAQs: Part 2

0.00/5 (No votes)
6 Sep 2005 1  
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.

Introduction

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
  • Security
  • SQL Server 2000/2005
  • COM/COM+
  • Web Services
  • Architecture/Design

FAQ

  1. 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.

  2. 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.
  3. 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.

  4. 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).

  5. 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.

  6. 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
  7. 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.

  8. 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.

  9. 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.

  10. 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.

  11. 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.

    • System
    • System.Collections
    • System.Collections.Specialized
    • System.Configuration
    • System.Text
    • System.Text.RegularExpressions
    • System.Web
    • System.Web.Caching
    • System.Web.Security
    • System.Web.SessionState
    • System.Web.UI
    • System.Web.UI.HtmlControls
    • System.Web.UI.WebControls
  12. 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.

  13. Why do some web service classes derive from System.Web.WebServices while others do not?

    Those Web Service classes which employ objects like Application, Session, Context, Server, and User have to derive from System.Web.WebServices. If it does not use these objects, it is not necessary to be derived from it.

  14. 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.

  15. 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.

  16. How do I create an ASPX page that periodically refreshes itself?

    The following META tag can be used as a trigger to automatically refresh the page every n seconds:

    <meta http-equiv="Refresh" content="nn">
  17. How do I initialize a TextBox whose TextMode is "password", with a password?

    The TextBox�s 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" />
  18. 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.

  19. How can the focus be set to a specific control when a Web form loads?

    This can be achieved by using client-side script:

    document.forms[0].TextBox1.focus ()

    The above code will set the focus to a TextBox named TextBox1 when the page loads.

  20. 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 __VIEWSTATE or __EVENTTARGET parameter. If there are none, then it is not a postback.

  21. 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)

  22. 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.

  23. 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.

  24. 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.

  25. 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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here