Click here to Skip to main content
15,867,453 members
Articles / Web Development / ASP.NET
Article

100 ASP.NET FAQs: Part 2

,
Rate me:
Please Sign up or sign in to vote.
3.27/5 (36 votes)
6 Sep 20056 min read 105.2K   70   3
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:

    HTML
    <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.NET
    <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:

    JavaScript
    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


Written By
Web Developer
United States United States
Narayana Rao Surapaneni is a Microsoft Certified Solution Developer for .NET, Microsoft Certified Solution Developer and a Sun Certified Java Professional.

He has received international acclaim for authoring dozens of industry papers on .NET and other Microsoft technologies for leading web sites and magazines. He is on the panel of contributors for IT magazine.

He has delivered many public seminars on the .NET framework, C#, web services, Service Oriented architecture and ASP.NET. Surapaneni lead Microsoft.NET & Web Services Center of Excellence.

His priorities include:

• Track technology/product releases
• Develop a strategy for each specific technology/product
• Develop methodologies/frameworks
• Develop prototypes and proof-of-concepts
• Microsoft.NET Framework 2.0/ASP.NET 2.0/ VS.NET 2005
• Integration and collaboration services
• Web Services and Service Oriented Orchitectures

He is the co-author of the following books:

1. Java & .NET: A Developer Guide to Interoperability and Migration (ISBN: 81-203-2444-7, http://www.prenticehallindia.com/)

2. Migrating to .Net: A Pragmatic Path to Visual Basic .Net, Visual C++ .Net and ASP .Net (ISBN: 0-13-100962-1, www.amazon.com)

3. Microsoft.NET Tutorial for beginners
(http://download.microsoft.com/download/8/e/7/8e725d96-7ec3-498b-9fa7-86779aed101f/dotNET%20Tutorial%20for%20Beginners.pdf)


Narayana Rao Surapaneni is a recipient of the world wide Most Valuable Professional Award by Microsoft (2002-2004). He was also awarded the Asia Most Valuable Professional by Microsoft. He is one of the charter members of MCSD.NET

When it comes to the suggesting a solution he emphasizes on the importance of well thought architectures and design principles. It is no surprise that many clients see him as the person whom they can approach to arrive at a right technology solution!

Written By
Web Developer
United States United States
Pradeep Rathinamuthu is a Microsoft certified Solution Developer and a CompTIA A+ Certified Associate. He has worked on numerous projects that involved developing, maintaining and implementing applications in VB, C++ and C#. He is currently working as a Programmer Analyst at the Microsoft.NET Center of Excellence at Ramco Systems Corporation, San Jose, CA. His current focus is on analyzing and developing solutions using the cutting-edge Dot Net technologies. Pradeep holds an MS in Computer Science from Illinois Institute of Technology, Chicago.

Comments and Discussions

 
GeneralMy vote of 1 Pin
Sanjay K. Gupta16-Jul-13 1:03
professionalSanjay K. Gupta16-Jul-13 1:03 
GeneralThanks Pin
aseef2-Apr-06 4:56
aseef2-Apr-06 4:56 
GeneralClient EXE From ASP.NET Page Pin
Manoj Kaklotar12-Oct-05 21:39
Manoj Kaklotar12-Oct-05 21:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.