xml documentation questions

Upload: pnitinm

Post on 10-Apr-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 XML Documentation Questions

    1/23

    XML Documentation Questions1.Is XML case-sensitive?

    Ans. Yes.

    2.Whats the difference between // comments,

    /* */ comments and /// comments?Ans. Single-line comments, multi-line comments,and XML documentation comments.

    3.How do you generate documentation from the C#file commented properly with a command-line compiler?

    Ans. Compile it with the /doc switch.

    Debugging and Testing Questions1.What debugging tools come with the .NET SDK?

    Ans.

    1. CorDBG command-line debugger. To useCorDbg, you must compile the original C# file

    using the /debug switch.

    2. DbgCLR graphic debugger. Visual Studio

    .NET uses the DbgCLR.

    2.What does assert() method do?

    Ans. In debug compilation, assert takes in a Boolean

    condition as a parameter, and shows the error

    dialog if the condition is false. The program proceeds

    without any interruption if the condition is true.

    3.Whats the difference between the Debug classand Trace class?

    Ans. Documentation looks the same. Use Debug class for

    debug builds, use Trace class for both debug and releasebuilds.

    4.Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

    Ans. The tracing dumps can be quite verbose. Forapplications that are constantly running you run the

    risk of overloading the machine and the hard drive.Five levels range from None to Verbose, allowing you tofine-tune the tracing activities.

    5.Where is the output of TextWriterTraceListenerredirected?

    Ans. To the Console or a text file depending on

    the parameter passed to the constructor.

  • 8/8/2019 XML Documentation Questions

    2/23

    6.How do you debug an ASP.NET Web application?

    Ans. Attach the aspnet_wp.exe process to theDbgClr debugger.

    7.What are three test cases you should go throughin unit testing?

    Ans.

    1. Positive test cases (correct data, correctoutput).

    2. Negative test cases (broken or missing data,

    proper handling).

    3. Exception test cases (exceptions are thrownand caught properly).

    8.Can you change the value of a variable while debugging

    a C# application?Ans. Yes. If you are debugging via Visual Studio.NET,

    just go to Immediate window.

    ADO.NET and Database Questions1. What is the role of the DataReader class in

    ADO.NET connections?

    Ans. It returns a read-only, forward-only rowset from

    the data source. A DataReader provides fast access

    when a forward-only sequential read is needed.

    2.What are advantages and disadvantages of Microsoftprovided data provider classes in ADO.NET?

    Ans. SQLServer.NET data provider is high-speed androbust, but requires SQL Server license purchased from

    Microsoft.

    OLE-DB.NET is universal for accessing other sources,

    like Oracle, DB2, Microsoft Access and Informix.OLE-DB.NET is a .NET layer on top of the OLE layer, so

    its not as fastest and efficient as SqlServer.NET.

    3.What is the wildcard character in SQL?Ans. Lets say you want to query database with LIKE for

    all employees whose name starts with La. The wildcard

    character is %, the proper query with LIKE wouldinvolve La%.

    4.Explain ACID rule of thumb for transactions.

    Ans.

  • 8/8/2019 XML Documentation Questions

    3/23

    A transaction must be:

    1.Atomic - it is one unit of work and does not dependent

    on previous and following transactions.2.Consistent - data is either committed or roll back, no

    in-between case where something has been updated and

    something hasnt.3.Isolated - no transaction sees the intermediate results

    of the current transaction).

    4.Durable - the values persist if the data had beencommitted even if the system crashes right after.

    5.What connections does Microsoft SQL Server support?

    Ans. Windows Authentication (via Active Directory) andSQL Server authentication (via Microsoft SQL Server

    username and password).

    6.Between Windows Authentication and SQL ServerAuthentication, which one is trusted and which one is

    untrusted?

    Ans. Windows Authentication is trusted because the

    username and password are checked with the Active

    Directory, the SQL Server authentication is untrusted,

    since SQL Server is the only verifier participating in thetransaction.

    7.What does the Initial Catalog parameter define in theconnection string?

    Ans. The database name to connect to.

    8.What does the Dispose method do with the connection

    object?

    Ans. Deletes it from the memory.To Do: answer better. The current answer is not entirely

    correct.

    9.What is a pre-requisite for connection pooling?

    Ans. Multiple processes must agree that they will share

    the same connection, where every parameter is the same,

    including the security settings. The connection stringmust be identical.

    Assembly Questions1.How is the DLL Hell problem solved in .NET?

    Ans. Assembly versioning allows the application to specify

    not only the library it needs to run (which was available

    under Win32), but also the version of the assembly.

  • 8/8/2019 XML Documentation Questions

    4/23

    2.What are the ways to deploy an assembly?

    Ans. An MSI installer, a CAB archive, and XCOPY command.

    3.What is a satellite assembly?

    Ans. When you write a multilingual or multi-culturalapplication in .NET, and want to distribute the core

    application separately from the localized modules, the

    localized assemblies that modify the core applicationare called satellite assemblies.

    4.What namespaces are necessary to create a localized

    application?

    Ans.System.Globalization and System.Resources.

    5.What is the smallest unit of execution in .NET?

    Ans. an Assembly.

    6.When should you call the garbage collector in .NET?

    Ans. As a good rule, you should not call the garbage

    collector. However, you could call the garbage collector

    when you are done using a large object (or set of objects)

    to force the garbage collector to dispose of those verylarge objects from memory. However, this is usually not a

    good practice.

    7.How do you convert a value-type to a reference-type?

    Ans. Use Boxing.

    8.What happens in memory when you Box and Unbox a

    value-type?

    Ans. Boxing converts a value-type to a reference-type, thusstoring the object on the heap. Unboxing converts a

    reference-type to a value-type, thus storing the value on

    the stack.

    Questions...

    1. What is the difference between a Struct and a Class?

    Ans.Structs are value-type variables and are thus savedon the stack -> additional overhead but faster retrieval. Another difference is that structs

    CANNOT inherit. Classes are reference types and structs are value types. Since classes

    are reference type, a class variable can be assigned null.But we cannot assign null to a

    struct variable, since structs are value type.

  • 8/8/2019 XML Documentation Questions

    5/23

    struct AStruct

    {

    int aField;}

    class AClass{

    int aField;}

    class MainClass

    {

    public static void Main(){

    AClass b = null; // No error.

    AStruct s = null; // Error

    /* [ Cannot convert null to 'AStruct' because it isa value type ].*/

    }}

    When you instantiate a class, it will be allocated on the heap.When you instantiate a

    struct, it gets created on the stack. You will always be dealing with reference to an

    object ( instance ) of a class. But you will not be dealingwith references to an instance of a struct ( but dealing directly with them ).

    When passing a class to a method, it is passed by

    reference. When passing a struct to a method, it's passedby value instead of as a reference.

    You cannot have instance Field initializers in structs.

    But classes can have initializers.

    class MyClass

    {int myVar =10; // no syntax error.

    public void MyFun( )

    {

    // statements}

    }

    struct MyStruct{

    int myVar = 10; //syntax error

    public void MyFun( )

  • 8/8/2019 XML Documentation Questions

    6/23

    {

    // statements

    }}

    Classes can have explicit parameterless constructors.But structs cannot have explicit parameterless constructors.

    class MyClass{

    int myVar = 10;

    public MyClass( ) // no syntax error.

    {// statements

    }

    }

    struct MyStruct

    {

    int myVar;

    public MyStruct( ) // syntax error.{

    // statements

    }}

    Classes must be instantiated using the new operator. But structs can be instantiated

    without using the new operator.

    MyClass aClassObj;/* MyClass aClassObj=new MyClass(); is the correct

    format.aClassObj.myVar=100;//NullReferenceException

    (because aClassObj does not contain a reference to an object

    of type myClass). */

    MyStruct aStructObj;aStructObj.myVar=100;// no exception.

    Classes support inheritance.But there is no inheritance for structs. ( structs don't support

    inheritance polymorphism )

    (1)

    struct MyStruct{

    int aStructVar;

    internal void aStructMethod(){

  • 8/8/2019 XML Documentation Questions

    7/23

    // statements

    }

    }

    class MyClass : MyStruct // Syntax error.

    {int aClassVar;

    int aClassMethod(){

    // statements

    }}

    (2)

    class MyClass

    {int aClassVar;

    int aClassMethod(){

    // statements

    }}

    struct MyStruct : MyClass // Syntax error.

    {

    int aStructVar;

    internal void aStructMethod(){

    // statements

    }}

    Since struct does not support inheritance, access modifier

    of a member of a struct cannot be protected or protectedinternal. It is not mandatory to initialize all Fields inside

    the constructor of a class. But all the Fields of a struct

    must be fully initialized inside the constructor.

    class MyClass //No error( No matter whether the Field//'MyClass.myString' is initialized or not ).

    {

    int myInt;

    string myString;public MyClass( int aInt )

    {

  • 8/8/2019 XML Documentation Questions

    8/23

    myInt = aInt;

    }

    }

    struct MyStruct // Error ( Field ' MyStruct.myString ' must

    //be fully assigned before it leaves the constructor ).{

    int myInt;string myString;

    public MyStruct( int aInt )

    { myInt = aInt;}

    }

    A class is permitted to declare a destructor.But a struct is not permitted to declare a

    destructor.

    struct MyStruct

    {int myInt;

    public MyStruct( )

    { } ~MyStruct( ) //Error.{

    Console.WriteLine("Destructor of MyStruct object");

    }

    }

    class MyClass{

    int myInt;

    public MyClass( ) { } ~MyClass( ) // No Error.{

    Console.WriteLine("Destructor of MyClass object"); }

    }

    Classes are used for complex and large set data. structs are

    simple to use. structs are useful whenever you need a type that will be used often and is

    mostly just a piece of data.

    2. What does the term immutable mean?

    Ans. It means to create a view of data that is not

    modifiable and is temporary of data that is

    modifiable.

  • 8/8/2019 XML Documentation Questions

    9/23

    Immutable means you can't change the currrent data,

    but if you perform some operation on that data, a

    new copy is created. The operation doesn't changethe data itself. Like let's say you have a string

    object having "hello" value. Now if you say

    temp = temp + "new value"

    a new object is created, and values is saved in that.The temp object is immutable, and can't be changed.

    An object qualifies as being called immutable if its value

    cannot be modified once it has been created. For example,

    methods that appear to modify a String actually return a newString containing the modification. Developers are

    modifying strings all the time in their code. This may

    appear to the developer as mutable - but it is not. Whatactually happens is your string variable/object has been

    changed to reference a new string value containing the

    results of your new string value. For this very reason

    .NET has the System.Text.StringBuilder class. If you findit necessary to modify the actual contents of a string-like object heavily, such as in a for

    or foreach loop, use the System.Text.StringBuilder class.

    3. Can we have private constructor? When can I

    use them? When should we implement a private constructor?

    Ans. Private constructors would be mainly used for singletonpatterns and for classes that are module-like

    (only static/shared methods/attributes)

    The idea of the singleton is that you don't have a publicconstructor, specifically to prevent people from

    instantiating more than one of them. You call a

    non-constructor method to return the singleton instance.If it doesn't exist, the method calls the private

    constructor to create it. Then it returns a reference

    to the singleton instance.

    An example below...

    // .NET Singletonsealed class Singleton

    {

    private Singleton() {}

  • 8/8/2019 XML Documentation Questions

    10/23

    public static readonly Singleton Instance = new Singleton();

    }

    Obviously you'd need to add some properties and methods to get something useful, butyou get the idea. Watch out for

    thread safety issues.

    This link may give more insight:ttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpSingletonInCsharp.asp

    4.Explain the differences between Server-side and

    Client-side code?

    Ans. Server side code will execute at server end

    all the business logic will execute at server end

    where as client side code will execute at client side

    at browser end. Usually, scripts like Javascript,

    VBScript & JScript etc. take care of client side

    funtions.

    5. What type of code (server or client) is found ina Code-Behind class?

    Ans. Server side.

    6.Should validation (Did the user enter a real date?)

    occur server-side or client-side? Why?

    Ans. Ideally it should occur client-side. It saves round-trip to server & thus saves time!!! It also avoids

    SQL Injections from malicious users. SQL injection is a security vulnerability that occurs in the databaselayer of an application. The vulnerability

    is present when user input is either incorrectly filteredfor string literal escape characters embedded in SQL

    statements or user input is not strongly typed and thereby

    unexpectedly executed. It is in fact an instance of a more

    general class of vulnerabilities that can occur wheneverone programming or scripting language is embedded inside another.

    Validation is usually done using client-side script likejavascript, jscript, vbscript (javascript being the most

    popular due to browser compatibility).

    .NET provides 5 + 1 controls for validation1- RequiredFieldValidator

    2- RangeValidator

    3- RegularExpressionValidator

    4- CompareValidator

    5- CustomValidator

    and the ValidationSummary Control

    7.What does the "EnableViewState" property do? Why

    would I want it on or off?

    Ans. It keeps the data of the control during post backs.

    if we turn off, the values should not populate during

    server round trip. Basically its used to sustain valueof control's attributes betwen postbacks.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpSingletonInCsharp.asphttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpSingletonInCsharp.asphttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpSingletonInCsharp.asp
  • 8/8/2019 XML Documentation Questions

    11/23

    When a form is submitted in classic ASP, all form values

    are cleared. Suppose you have submitted a form with a lot of information and the server comes back with

    an error. You will

    have to go back to the form and correct the information. You click the back button, and what happens.......

    ALL form values are CLEARED, and you will have to start allover again! The site did not maintain your ViewState.

    When a form is submitted in ASP .NET, the form reappears in

    the browser window together with all form values. How come?

    This is because ASP .NET maintains your ViewState. The ViewState indicates the status of the page when

    submitted to the server.

    The status is defined through a hidden field placed on each pagewith a control.

    Maintaining the ViewState is the default setting for ASP.NET

    Web Forms. If you want to NOT maintain the ViewState, include the directive at the top of an .aspx page or add the attribute EnableViewState="false" to

    any control.

    8. What is the difference between Server.Transfer and

    Response.Redirect? Why would I choose one over the other?

    Ans. Server.Transfer will prevent round trip. it will

    redirect pages which or in the same directory. NO way to

    pass the query strings . Thru http context we can able

    to get the previous page control values.

    Response.Redirect : There is a round trip to process therequest. We can redirect to any page external / internal

    other than aspx. We can pass the query string thru which we

    can manage sessions.

    A common misconception is the difference between Server.Transfer and Response.Redirect in ASP.NET

    applications. Redirect and Transfer both cause a new page to be processed, but the interaction between the

    client (web browser) and server(ASP.NET) is different in each situation.

    Redirect: A redirect is just a suggestion its like saying

    to the client Hey, you might want to look at this. All you tell the client is the new URL to look at, and if

    they comply,

    they do a second request for the new URL.

    If you want to pass state from the source page to the new

    page, you have to pass it either on the URL (such as a database key, or message string), or you can store itin the Session

    object (caveat: there may be more than one browser window, and theyll all use the same session object).

    e.g. Redirect to the new.aspx page, passing an ID on the

    query string. "true" stops processing the current page:

    Response.Redirect("new.aspx?id=32", true);

  • 8/8/2019 XML Documentation Questions

    12/23

    Transfer: A transfer happens without the client knowing

    its the equivalent of a client requesting one page,

    but being given another. As far as the client knows, they

    are still visiting the original URL.

    Sharing state between pages is much easier using

    Server.Transfer you can put values into the Context.Itemsdictionary, which is similar to Session and Application,

    except that it lasts only for the current request. (search

    for HttpContext in MSDN). The page receiving postback can

    process data, store values in the Context, and then Transfer

    to a page that uses the values. e.g. Store a message in the context dictionary, and transfer to the default.aspxpage (which can then display the message):

    Context.Items["Message"] = "Your password was changed successfully";

    Server.Transfer("default.aspx");

    Response.Redirect is more user-friendly, as the site visitor can

    bookmark the page that they are redirected to. Transferred pages appear to the client as a different url than

    they really are.This means that things like relative links/image paths may not

    work if you transfer to a page from a different directory.

    Server.Transfer has an optional parameter to pass the form data

    to the new page. Since the release version, this no longer works, because the Viewstate now has more

    security by default (The

    EnableViewStateMac defaults to true), so the new page isnt able to access the form data. You can still

    access the values of the original page in the new page, by requesting the original handler:

    Page originalPage = (Page)Context.Handler;

    TextBox textBox1 = (TextBox)originalPage.FindControl("textBox1");

    9. Can you give an example of when it would be appropriate

    to use a web service as opposed to a non-serviced .NET

    component.

    Ans. Web service is one of main component in Service Oriented

    Architecture. You could use web services when your clients and servers are running on different networks

    and also different platforms. This provides a loosely coupled system. And also if the client is behind the

    firewall it would be easy to use web service since it runs on port 80 (by default) instead of having some

    thing else in Service Oriented Architecture applications.What is the standard you use to wrap up a call to a Web service?

    Ans. SOAP.

    Web services are best suite for Hetrogenious

    environment. Remoting is best suite for Homogenious environment where the system is under CLR.

    10. Let's say I have an existing application written using

    Visual Studio 6 (VB 6, InterDev 6) and this application utilizes Windows 2000 COM+ transaction

    services. How would you approach migrating this application to .NET?

    Ans. .NET has made excellent use of the existing COM+Technology to provide component features like instance management, transactions, activity-based

    synchronization,

  • 8/8/2019 XML Documentation Questions

    13/23

    granular role-based security, disconnected asynchronous queued

    components, and loosely coupled events. This integration is a

    big leap forward, providing greater flexibility to developers

    through code.

    The .NET components, which make use of the COM+ Services, are termed as ServicedComponents. Must

    read this link to learn more : http://msdn2.microsoft.com/en-us/library/ms973809.aspx

    11. Can you explain the difference between an ADO.NET

    Dataset and ADO Recordset?

    Ans. In ADO, the in-memory representation of data is the

    recordset. In ADO.NET, it is the dataset. There are important differences between them.

    Number of Tables

    A recordset looks like a single table. If a recordset is to contain data from multiple database tables, it must

    use a JOIN query, which assembles the data from the various database tables into a single result table. In

    contrast, a dataset is a collection of one or more tables. The tables within a dataset are called data tables;

    specifically, they are DataTable objects. If a dataset contains data from multiple database tables, it will

    typically contain multiple DataTable objects. That is, each DataTable object typically corresponds to asingle database table or view. In this way, a dataset can mimic the structure of the underlying database.

    A dataset usually also contains relationships. A relationship within a dataset is analogous to a foreign-key

    relationship in a database that is, it associates rows of the tables with each other. For example, if a

    dataset contains a table about investors and another table about each investor's stock purchases, it could

    also contain a relationship connecting each row of the investor table with the corresponding rows of the

    purchase table. Because the dataset can hold multiple, separate tables and maintain information about

    relationships between them, it can hold much richer data structures than a recordset, including self-relating

    tables and tables with many-to-many relationships.

    Data Navigation and Cursors

    In ADO you scan sequentially through the rows of the recordset using the ADO MoveNext method. InADO.NET, rows are represented as collections, so you can loop through a table as you would through any

    collection, or access particular rows via ordinal or primary key index. DataRelation objects maintain

    information about master and detail records and provide a method that allows you to get records related to

    the one you are working with. For example, starting from the row of the Investor table for "Nate Sun," you

    can navigate to the set of rows of the Purchase table describing his purchases.

    A cursor is a database element that controls record navigation, the ability to update data, and the visibility

    of changes made to the database by other users. ADO.NET does not have an inherent cursor object, but

    instead includes data classes that provide the functionality of a traditional cursor. For example, the

    functionality of a forward-only, read-only cursor is available in the ADO.NET DataReader object. For

    more information about cursor unctionality, see Data Access Technologies.

    Minimized Open Connections

    In ADO.NET you open connections only long enough to perform a database operation, such as a Select or

    Update. You can read rows into a dataset and then work with them without staying connected to the data

    source. In ADO the recordset can provide disconnected access, but ADO is designed primarily for

    connected access.

    There is one significant difference between disconnected processing in ADO and ADO.NET. In ADO you

    communicate with the database by making calls to an OLE DB provider. In ADO.NET you communicatewith the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or

    http://msdn2.microsoft.com/en-us/library/ms973809.aspxhttp://msdn2.microsoft.com/en-us/library/ms973809.aspx
  • 8/8/2019 XML Documentation Questions

    14/23

    OracleDataAdapter object), which makes calls to an OLE DB provider or the APIs provided by the

    underlying data source. The important difference is that in ADO.NET the data adapter allows you to

    control how the changes to the dataset are transmitted to the database by optimizing for performance,

    performing data validation checks, or adding any other extra processing.

    Note - Data adapters, data connections, data commands, and data readers are the components that make up

    a .NET Framework data provider. Microsoft and third-party providers can make available other .NETFramework data providers that can be integrated into Visual Studio. For information on the different .NET

    Data providers, see .NET Data Providers.

    Sharing Data Between Applications

    Transmitting an ADO.NET dataset between applications is much easier than transmitting an ADO

    disconnected recordset. To transmit an ADO disconnected recordset from one component to another, youuse COM marshalling. To transmit data in ADO.NET, you use a dataset, which can transmit an XML

    stream.

    12. Can you give an example of what might be best suited to place in the Application_Start and

    Session_Start subroutines?

    Ans. The Application_Start event is guaranteed to occur only once throughout the lifetime of the

    application. Its a good place to initialize global variables. For example, you might want to retrieve a list of

    products from a database table and place the list in application state or the Cache object.

    SessionStateModule exposes both Session_Start and Session_End events.

    13. If I'm developing an application that must accomodate

    multiple security levels through secure login and my ASP.NET web appplication is spanned across

    three web-servers (using round-robbin load balancing)

    what would be the best approach to maintain login-in state

    for the users?

    Ans. Database Support OR through State Service

    14. What are ASP.NET Web Forms? How is this technology

    different than what is available though ASP (1.0-3.0)?

    Ans. There are plenty of differences.

    ASP Interpreter.. use the script engine.

    ASP.Net is compiled as managed code within the CLR. It also

    supports code-behind (unlike in ASP, where code=behind was

    invoked through VB components).

    15. How does VB.NET/C# achieve polymorphism?

    Ans. We achieve it using Function overloading & Operator overloading.

    Polymorphism by definition means taking many forms. In C# it means the ability for classes to share the

    same methods (actions) but implement them differently. For instance, say we create a class called "Shape"

    and this class has a method called .draw() which draws the shape onto the user interface. Then we create

    two subclasses, using inheritance, of this Shape class. One called Square, the other called Circle. Now

    obviously a square and circle are two entirely different shapes, yet both classes have the .draw() method.

    When the Square.draw() method is called it will draw a square on the user interface. When the

    Circle.draw() method is called, it will draw a circle on the user interface. So both classes can use the samemethods but implement them differently.

  • 8/8/2019 XML Documentation Questions

    15/23

    16. Can you explain what inheritance is and an example

    of when you might use it?

    Ans. Inheriting a trait from a parent class!Use the existing functionality along with its own

    properities.

    17. How would you implement inheritance using VB.NET/C#?

    Ans. Derived Class : BaseclassVB.NEt : Derived Class Inherits Baseclass

    18. Whats an assembly ?

    Ans. A Basic unit of executable code.

    * It contains : Manifest - Meta data* versioning , Culture , IL, Reference

    19. Describe the difference between inline and code behind.

    Ans. Inline function bind at compile time can write in aspx page with in .

    The code-behind is in a CS or a VB file.

    20. Explain what a diffgram is, and a good use for one.

    Ans. A DiffGram is an XML format that is used to identify

    current and original versions of data elements. The DataSet uses the DiffGram format to

    load and persist its contents, and to serialize its contents for transport across a network

    connection. When a DataSet is written as a DiffGram, it populates the DiffGram with allthe necessary information to accurately recreate the contents, though not the schema, of

    the DataSet, including column values from both the Original and Current row versions,row error information, and row order. When sending and retrieving a DataSet from an

    XML Web service, the DiffGram format is implicitly used.

    Additionally, when loading the contents of a DataSet from

    XML using the ReadXml method, or when writing thecontents of a DataSet in XML using the WriteXml method,

    you can select that the contents be read or written as a

    DiffGram

    DiffGram FormatThe DiffGram format is divided into three sections: the

    current data, the original (or "before") data, and an

    errors section, as shown in the following example.

  • 8/8/2019 XML Documentation Questions

    16/23

    xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"

    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    The DiffGram format consists of the following blocks of data:

    The name of this element, DataInstance, is used for

    explanation purposes in this documentation. A DataInstanceelement represents a DataSet or a row of a DataTable.

    Instead of DataInstance, the element would contain the nameof the DataSet or DataTable. This block of the DiffGram format contains the current data,

    whether it has been modified or not.

    An element, or row, that has been modified is identified withthe diffgr:hasChanges annotation.

    This block of the DiffGram format contains the original

    version of a row. Elements in this block are matched to

    elements in the DataInstance block using the diffgr:idannotation.

    This block of the DiffGram format contains error information

    for a particular row in the DataInstance block. Elements in

    this block are matched to elements in the DataInstance block

    using the diffgr:id annotation.

    21. Where would you use an iHTTPModule, and what arethe limitations of any approach you might take inimplementing one?

    Ans. It provides module initialization and disposal eventsto the implementing class.

    22. Compare Session State Vs. ViewState.Ans. Session State is useful for storing values that mustbe persisted across multiple pages by the same user. ViewState is useful forstoring serializable data that must be

    http://www.w3.org/2001/XMLSchemahttp://www.w3.org/2001/XMLSchema
  • 8/8/2019 XML Documentation Questions

    17/23

    persisisted across PostBacks by a single page. If you useSession State, the value you insert will remain in memoryuntil (1) The Session times out, or (2) Your code removes it.If you use ViewState, the value you insert will remain inViewState until the user requests a different page.

    ViewState stores data betwen PostBacks by putting it into ahidden form field on the client HTML doc. when the doc isPosted Back, the values are read from the hidden form fieldand stored in memory until the page has finished processing.If ViewState is particularly large (and I'm talking KBs

    here, not 6 bytes), it can negatively affect the speed atwhich the HTML doc is downloaded by the browser.

    24. Whats MSIL, and why should my developers need an appreciation of it if at all?

    Ans. Microsoft Intermediate language. which is the out put

    for all the .net supported languages after compilation will

    produce. Appreciation is for cross language support.Definition:Microsoft Intermediate Language (MSIL) is the

    CPU-independent instruction set generated by .NET compilersfrom .NET languages such as J#, C# or Visual Basic. MSIL is

    compiled before or during execution of the program by a Virtual Execution System

    (VES), which is part of the Common Language Runtime module (CLR).

    25. In what order do the events of an ASPX page execute. As a developer is it

    important to undertsand these events?

    Ans.

    Page request

    The page request occurs before the page life cycle begins.

    When the page is requested by a user, ASP.NET determines

    whether the page needs to be parsed and compiled (therefore beginning the life of apage), or whether a cached version

    of the page can be sent in response without running the page.

    Start

    In the start step, page properties such as Request and

    Response are set. At this stage, the page also determines

    whether the request is a postback or a new request and setsthe IsPostBack property. Additionally, during the start step,

    the page's UICulture property is set.

    Page initialization

    During page initialization, controls on the page are

    available and each control's UniqueID property is set. Anythemes are also applied to the page. If the current request is

    a postback, the postback data has not yet been loaded and

    control property values have not been restored to the values

    from view state.

  • 8/8/2019 XML Documentation Questions

    18/23

    Load

    During load, if the current request is a postback, controlproperties are loaded with information recovered from view

    state and control state.

    ValidationDuring validation, the Validate method of all validator

    controls is called, which sets the IsValid property ofindividual validator controls and of the page.

    Postback event handling

    If the request is a postback, any event handlers are called.Rendering Before rendering, view state is saved for the page and all controls. During the

    rendering phase, the page calls the Render method for each control, providing a text

    writer that writes its output to the OutputStream of the page's Response property.

    UnloadUnload is called after the page has been fully rendered, sent

    to the client, and is ready to be discarded. At this point,

    page properties such as Response and Request are unloaded and any cleanup is

    performed.

    26. Which method do you invoke on the DataAdapter

    control to load your generated dataset with data?

    Ans. Fill()

    27. Can you edit data in the Repeater control?

    Ans.NO

    28. Which template must you provide, in order to displaydata in a Repeater control?

    Ans. ITemtemplate

    29. How can you provide an alternating color scheme in a Repeatercontrol?

    Ans. AlternateItemTemplate

    30. What property must you set, and what method must you call in your code, in

    order to bind the data from some data source to the Repeatercontrol?

    Ans. Datasource, DataBind

    31. What base class do all Web Forms inherit from?

    Ans. System.Web.UI.Page

  • 8/8/2019 XML Documentation Questions

    19/23

    32. What method do you use to explicitly kill a user's

    session?

    Ans. Abandon()

    33. How do you turn off cookies for one page in your site?

    Ans. Disablecookies.

    34. Which two properties are on every validation control?

    Ans. Control to validate, Error message

    35. What tags do you need to add within the

    asp:datagrid tags to bind columns manually?

    Ans. autogenerated columns is set to false

    36. How do you create a permanent cookie?

    Ans. Setting a permanent cookie is no harder than setting a

    Session cookie. Its very similar, except you give the cookiean expiration date as well. It is very common that you dont

    specify any arbitrary expiration date, but instead expire thecookie relative to the current date, using the DateAdd()

    function, built into ASP. If you want to create a permanent

    cookie called Name with a value of Nigel, which expires in one

    month, youd use the following code

    Response.Cookies("Name") = "Nigel"

    Response.Cookies("Name").Expires = DateAdd("m", 1, Now())

    Its that easy! Nothing more to it. You have now set a permanent cookie on your

    computer. Also, note that whenever the above code is called the expiration date of thecookie is renewed by one month from now.

    There are a few more options which you can set, like for example the Path option. You

    can limit cookies to certain paths on your website, so you can set several cookies with thesame name, as long as they belong to different paths. To do this, you would use the

    following code (extending the previous code):

    Response.Cookies("Name").Path = "/foo/"The above code would limit the cookie to the path foo. It is

    also possible to assign multiple values to a particular cookie.

    This is done using the so-called dictionary functionality ofa cookie. For example, if Id want to store not only the first

    name, but also the surname in my Name cookie, Id be using

    something like the following code:

    Response.Cookies("Name")("First") = "Nigel"

    Response.Cookies("Name")("Last") = "Pallett"

    Response.Cookies("Name").Expires = DateAdd("m", 1, Now())

  • 8/8/2019 XML Documentation Questions

    20/23

    Thats all! Although there are a few more "advanced" options,

    such as the Secure option and the Domain option, it is of no use now.

    Retrieving Cookies

    Retrieving the value of cookies is a very easy job, becauseagain everything is handled by the browser and your server.

    All you have to use is ASPs inbuilt functions.

    There is no difference in retrieving a Session cookie or apermanent cookie, and in both cases you use the following code:

    Response.Write "Your Name: " & Request.Cookies("Name")

    The above is for when you assigned only one value to a cookie. If you assigned multiple

    values you a cookie, you use the following code:

    Response.Write "Your First Name: " & _Request.Cookies("Name")("First")

    Response.Write "Your Surname: " & _Request.Cookies("Name")("Last")

    Thats all there is to it. Its that easy, because everything

    is done by your server and the ASP engine. Make sure you check out this handy functionas well, which shows your visitors all the cookies they have stored.

    Checking if Cookies are enabledBefore using cookies, it is often useful to check whether your

    visitor accepts cookies. Some may disable it in their browser;

    others may be using browsers that dont support cookies at all (although very fewbrowsers do). You should always keep the fact that your cookies might not work in the

    back of your mind, meaning, do NOT rely on cookies to work. If your website does not

    work when cookies are disabled, you must fix this.

    37. What tag do you use to add a hyperlink column to

    the DataGrid?

    Ans.

    38. What is the standard you use to wrap up a call to a

    Web service?

    Ans. SOAP - SOAP is a simple XML-based protocol to let

    applications exchange information over HTTP.

    SOAP (originally Simple Object Access Protocol) is aprotocol for exchanging XML-based messages over computer

    network, normally using HTTP. SOAP forms the foundation

    layer of the Web services stack, providing a basic messaging

    framework that more abstract layers can build on. The original acronym was dropped

  • 8/8/2019 XML Documentation Questions

    21/23

    with Version 1.2 of the standard, which became a W3C Recommendation on June 24,

    2003, as it was

    considered to be misleading.

    There are several different types of messaging patterns in

    SOAP, but by far the most common is the Remote Procedure Call (RPC) pattern, inwhich one network node (the client) sends a request message to another node (the server),

    and the server immediately sends a response message to the client. SOAP is the successor

    of XML-RPC, though it borrows its transport and interaction neutrality and theenvelope/header/body from elsewhere, probably from WDDX [citation needed].

    Originally designed by Dave Winer, Don Box, Bob Atkinson, and Mohsen Al-Ghosein in

    1998 with backing from Microsoft (where Atkinson and Al-Ghosein worked at the time)

    as an object-access protocol, the SOAP specification is currently maintained by the XMLProtocol Working Group of the World Wide Web Consortium.

    39. Which method do you use to redirect the user to

    another page without performing a round trip to the client?Ans. Server.transfer

    40. What is the transport protocol you use to call a

    Web service

    Ans.

    SOAP. Transport Protocols: It is essential for the acceptance of Web Services that theyare based on established Internet

    infrastructure. This in fact imposes the usage of of the HTTP,

    SMTP and FTP protocols based on the TCP/IP family oftransports. Messaging Protocol: The format of messages exchanged between Web

    Services clients and Web Services should be vendor neutral and should not carry details

    about the technology used to implement the service. Also, the message format shouldallow for extensions and different bindings to specific transport protocols. SOAP and

    ebXML Transport are specifications which fulfill these requirements. We expect that the

    W3C XML Protocol Working Group defines a successor standard.

    41. True or False: A Web service can only be written

    in .NET

    Ans. False

    42. What does WSDL stand for?

    Ans.Webservice description language. WSDL is an XML format for describing network

    services as a set of endpointsoperating 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 concreteendpoints are combined into abstract endpoints (services). WSDL is extensible to allow

    description of endpoints and their messages regardless of what message formats or

    network protocols are used to communicate, however, the only bindings described in this

  • 8/8/2019 XML Documentation Questions

    22/23

    document describe how to use WSDL in conjunction with SOAP 1.1, HTTP GET/POST,

    and MIME.

    43. What property do you have to set to tell the

    grid which page to go to when using the Pager object?

    Ans. Page Index.

    44. Where on the Internet would you look for Web services?

    Ans. UDDI

    45. What tags do you need to add within the

    asp:datagrid tags to bind columns manually.

    Ans. Autogenerate columns

    46. 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?

    Ans. Datatext, Datavalue

    47. How is a property designated as read-only?Ans.

    In VB.NET:Public ReadOnly Property PropertyName As ReturnType

    Get Your Property Implementation goes in here

    End Get

    End PropertyIn C#

    public returntype PropertyName

    {get{

    //property implementation goes here

    }// Do not write the set implementation

    }

    48. Which control would you use if you needed to make sure the values in two

    different controls matched?

    Ans. Ideally we would tend to use Comparefield validator.

    49. True or False: To test a Web service you must create a windows application or

    Web application to consume this service?

    Ans. False

    50. How many classes can a single .NET DLL contain?

    Ans. As many as u want!

    51.Is ASP.NET a language?Ans.No! Its a technology.

    ASP.NET is not a platform independent language. As was

  • 8/8/2019 XML Documentation Questions

    23/23

    ASP.NET is more of a technology that provides a framework for building web

    applications. ASP.NET provides the reources needed to dynamically deliver html content

    (pages) to the end user. ASP.NET can leverage languages such as C#, VB.NET, andjavascript to help provide a reliable, high perfofmance, and secure web application.