QA

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 19

1.

Whats the difference between Response.Write() andResponse.Output.Write()?

Response.Output.Write() allows you to write formatted output. 2. When during the page processing cycle is ViewState available?

After the Init() and before the Page_Load(), or OnLoad() for a control. 3. What namespace does the Web page belong in the .NET Framework class hierarchy?

System.Web.UI.Page 4. Where do you store the information about the users locale?

CodeBehind is relevant to Visual Studio.NET only. 5. Whats the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?

CodeBehind is relevant to Visual Studio.NET only. 6. What is the Global.asax used for?

The Global.asax (including the Global.asax.cs file) is used to implementapplication and session level events. 7. What are the Application_Start and Session_Start subroutines used for?

This is where you can set the specific variables for the Application and Session objects. 8. Whats an assembly?

Assemblies are the building blocks of the .NET framework; 9. Whats MSIL, and why should my developers need an appreciation of it if at all?

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. 10. Which method do you invoke on the DataAdapter control to load your generated dataset with data? The Fill() method. 11. Can you edit data in the Repeater control? No, it just reads the information from its data source. 12. Which template must you provide, in order to display data in a Repeater control? ItemTemplate. 13. Name two properties common in every validation control? ControlToValidate property and Text property. 14. What base class do all Web Forms inherit from? The Page class.

15. What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? 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 less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the user's browser to another page or site. This performas 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 16. What is the lifespan for items stored in ViewState? Item stored in ViewState exist for the life of the current page. This includes postbacks (to the same page). 17. What does the "EnableViewState" property do? Why would I want it on or off? 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. 18. 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. 19. 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. 20. Can a .NET web application consume Java web service ? Yes.Actually Webservices are independent to language. it depends on WSDL and SOAP. so any one can developed the Web services and disclose the wsdl and users can consume the webservices.wsdl and soap both are xml based.. and all languages having xml parsing capability and access to http protocol will be able to work with Webservices 21. What is IsPostBack? How to use it? IsPostBack event is generated by the web controls to alert the server to take respected action of the event generated. When the button is clicked then click event is generated which further cause IsPostBack event & it alerts the server to take respected action during postback event. 22. In order to get assembly info which namespace we should import? system.reflection 23. Which method do you invoke on the DataAdapter control to load your generated dataset with data? dataadapter.fill(dataset object)

24. Enumerate the types of Directives? @ Page directive @ Assembly directive @ Import directive @ Reference directive @ Implements directive @ OutputCache directive @ Register directive 25. What is a DataReader? A DataReader is a read-only stream of data returned from the database as the query executes. It only contains one row of data in memory at a time and is restricted to navigating forward only in the results one record at a time. The DataReader does support access to multiple result sets, but only one at a time and in the order retrieved. Just as in the original version of ADO, the data is no longer available through the DataReader once the connection to the data source is closed, which means a DataReader requires a connection to the database throughout its usage. Output parameters or return values are only available through the DataReader once the connection is closed. 26. Why DataReader Useful? Data Reader is Read only version Data Set,Each record is returned as a Data Reader Object,ExecuteReader method acts directly on the database connection. There are two versions of the data reader object: OleDbDataReader and SqlDataReader 27. Difference between DataReader and DataSet The Dataset is an core of disconnected architecture.Disconnected architecture means once you have retriveed the data from the database the connect of the datasource is dropped.The disconnected data become very commonlyThe dataset for the disconnected data from the Dataset object.The DataReader is an readonly ,forward only stream from the database.While using the datareader can improve the application performance reduce the system overhead because only one buffer row at a time in memory. 28. Explain the advantages of ASP.NET. Following are the advantages of ASP.NET. Web application exists in compiled form on the server so the execution speed is faster as compared to the interpreted scripts. ASP.NET makes development simpler and easier to maintain with an event-driven, server-side programming model. Being part of .Framework, it has access to all the features of .Net Framework. Content and program logic are separated which reduces the inconveniences of program maintenance. ASP.NET makes for easy deployment. There is no need to register components because the configuration information is built-in. To develop program logic, a developer can choose to write their code in more than 25 .Net languages including VB.Net, C#, JScript.Net etc. Introduction of view state helps in maintaining state of the controls automatically between the postbacks events. ASP.NET offers built-in security features through windows authentication or other authentication methods.

Integrated with ADO.NET. Built-in caching features.

29. Explain the different parts that constitute ASP.NET application. Content, program logic and configuration file constitute an ASP.NET application. Content files : Content files include static text, images and can include elements from database. Program logic : Program logic files exist as DLL file on the server that responds to the user actions. Configuration file : Configuration file offers various settings that determine how the application runs on the server. 30. Explain the components of web form in ASP.NET Server controls : The server controls are Hypertext Markup Language (HTML) elements that include a runat=server attribute. They provide automatic state management and server-side events and respond to the user events by executing event handler on the server. HTML controls : These controls also respond to the user events but the events processing happen on the client machine. Data controls : Data controls allow to connect to the database, execute command and retrieve data from Database: System Components: System components provide access to system-level events that occur on the server. 31. Describe in brief .NET Framework and its components. .NET Framework provides platform for developing windows and web software. ASP.NET is a part of .Net framework and can access all features implemented within it that was formerly available only through windows API. .NET Framework sits in between our application programs and operating system. The .Net Framework has two main components : .Net Framework Class Library : It provides common types such as data types and object types that can be shared by all .Net compliant language. The Common language Runtime : It provides services like type safety, security, code execution, thread management, interoperability services. 32. What is an Assembly? Explain its parts? An assembly exists as a .DLL or .EXE that contains MSIL code that is executed by CLR. An assembly contains interface and classes, it can also contain other resources like bitmaps, files etc. It carries version details which are used by the CLR during execution. Two assemblies of the same name but with different versions can run side-by-side enabling applications that depend on a specific version to use assembly of that version. An assembly is the unit on which permissions are granted. It can be private or global. A private assembly is used only by the application to which it belongs, but the global assembly can be used by any application in the system. The four parts of an assembly are: Assembly Manifest - It contains name, version, culture, and information about referenced assemblies. Type metadata - It contains information about types defined in the assembly. MSIL - MSIL code. Resources - Files such as BMP or JPG file or any other files required by application.

33. Define Common Type System. .Net allows developers to write program logic in at least 25 languages. The classes written in one language can be used by other languages in .Net. This service of .Net is possible through CTS which ensure the rules related to data types that all language must follow. It provides set of types that are used by all .NET languages and ensures .NET language type compatibility. 34. Define Virtual folder. It is the folder that contains web applications. The folder that has been published as virtual folder by IIS can only contain web applications. 35. Describe the Events in the Life Cycle of a Web Application A web application starts when a browser requests a page of the application first time. The request is received by the IIS which then starts ASP.NET worker process (aspnet_wp.exe). The worker process then allocates a process space to the assembly and loads it. An application_start event occurs followed by Session_start. The request is then processed by the ASP.NET engine and sends back response in the form of HTML. The user receives the response in the form of page. The page can be submitted to the server for further processing. The page submitting triggers PostBack event that causes the browser to send the page data, also called as view state to the server. When server receives view state, it creates new instance of the web form. The data is then restored from the view state to the control of the web form in Page_Init event. The data in the control is then available in the Page_load event of the web form. The cached event is then handled and finally the event that caused the PostBack is processed. The web form is then destroyed. When the user stops using the application, Session_end event occurs and session ends. The default session time is 20 minutes. The application ends when no user accessing the application and this triggers Application_End event. Finally all the resources of the application are reclaimed by the Garbage collector. 36. What are the ways of preserving data on a Web Form in ASP.NET? ASP.NET has introduced view state to preserve data between PostBack events. View state cant avail data to other web form in an application. To provide data to other forms, you need to save data in a state variable in the application or session objects. 37. Define application state variable and session state variable. These objects provide two levels of scope: Application State Data stored in the application object can be shared by all the sessions of the application. Application object stores data in the key value pair.

Session State Session State stores session-specific information and the information is visible within the session only. ASP.NET creates unique sessionId for each session of the application. SessionIDs are maintained either by an HTTP cookie or a modified URL, as set in the applications configuration settings. By default, SessionID values are stored in a cookie.

38. Describe the application event handlers in ASP.NET Following are the application event handlers: Application_Start: This event occurs when the first user visits a page of the application. Application_End: This event occurs when there are no more users of the application. Application_BeginRequest: This occurs at the beginning of each request to the server. Application_EndRequest: occurs at the end of each request to the server. Session_Start: This event occurs every time when any new user visits. Session_End: occurs when the users stop requesting pages and their session times out.

39. What are the Web Form Events available in ASP.NET? Page_Init Page_Load Page_PreRender Page_Unload Page_Disposed Page_Error Page_AbortTransaction Page_CommitTransaction Page_DataBinding 40. Describe the Server Control Events of ASP.NET. ASP.NET offers many server controls like Button, TextBox, DropDownList etc. Each control can respond to the user s actions using events and event handler mechanism. There are three types of server control events: Postback events : This events sends the web page to the server for processing. Web page sends data back to the same page on the server. Cached events : These events are processed when a PostBack event occurs. Validation events : These events occur just before a page is posted back to the server. 41. How do you change the session time-out value? The session time-out value is specified in the web.config file within sessionstate element. You can change the session time-out setting by changing value of timeout attribute of sessionstate element in web.config file. 42. Describe how ASP.NET maintains process isolation for each Web application? In ASP.NET, when IIS receives a request, IIS uses aspnet_isapi.dll to call the ASP.NET worker process (aspnet_wp.exe). The ASP.NET worker process loads the Web application s assembly, allocating one process space, called the application domain, for each application. This is the how ASP.NET maintains process isolation for each Web application. 43. Define namespace. Namespaces are the way to organize programming code. It removes the chances of name conflict. It is quite possible to have one name for an item accidentally in large projects those results into conflict. By organizing your code into namespaces, you reduce the chance of these conflicts. You can create namespaces by enclosing a class in a Namespace End Namespace block.

You can use namespaces outside your project by referring them using References dialog box. You can use Imports or using statement to the code file to access members of the namespaces in code. 44. What are the options in ASP.NET to maintain state? Client-side state management - This maintains information on the clients machine using Cookies, View State, and Query Strings. Cookies : A cookie is a small text file on the client machine either in the clients file system or memory of client browser session. Cookies are not good for sensitive data. Moreover, Cookies can be disabled on the browser. Thus, you cant rely on cookies for state management. View State : Each page and each control on the page has View State property. This property allows automatic retention of page and controls state between each trip to server. This means control value is maintained between page PostBacks. Viewstate is implemented using _VIEWSTATE, a hidden form field which gets created automatically on each page. You cant transmit data to other page using view state. Querystring : Query strings can maintain limited state information. Data can be passed from one page to another with the URL but you can send limited size of data with the URL. Most browsers allow a limit of 255 characters on URL length. Server-side state management - This kind of mechanism retains state in the server. Application State : The data stored in the application object can be shared by all the sessions of the application. Application object stores data in the key value pair. Session State : Session State stores session-specific information and the information is visible within the session only. ASP.NET creates unique sessionId for each session of the application. SessionIDs are maintained either by an HTTP cookie or a modified URL, as set in the applications configuration settings. By default, SessionID values are stored in a cookie. Database : Database can be used to store large state information. Database support is used in combination with cookies or session state. 45. Explain the difference between Server control and HTML control. Server events - Server control events are handled in the server whereas HTML control events are handled in the page. State management - Server controls can maintain data across requests using view state whereas HTML controls have no such mechanism to store data between requests. Browser detection - Server controls can detect browser automatically and adapt display of control accordingly whereas HTML controls cant detect browser automatically. Properties - Server controls contain properties whereas HTML controls have attributes only. 46. What are the validation controls available in ASP.NET? ASP.NET validation controls are: RequiredFieldValidator: This validates controls if controls contain data. CompareValidator: This allows checking if data of one control match with other control. RangeValidator: This verifies if entered data is between two values.

RegularExpressionValidator: This checks if entered data matches a specific format. CustomValidator: Validate the data entered using a client-side script or a server-side code. ValidationSummary: This allows developer to display errors in one place.

47. Define the steps to set up validation control. Following are the steps to set up validation control Drag a validation control on a web form. Set the ControlToValidate property to the control to be validated. If you are using CompareValidator, you have to specify the ControlToCompare property. Specify the error message you want to display using ErrorMessage property. You can use ValidationSummary control to show errors at one place.

48. What are the navigation ways between pages available in ASP.NET? Ways to navigate between pages are: Hyperlink control Response.Redirect method Server.Transfer method Server.Execute method Window.Open script method

49. How do you open a page in a new window? To open a page in a new window, you have to use client script using onclick="window.open()" attribute of HTML control. 50. Define authentication and authorization. Authorization : The process of granting access privileges to resources or tasks within an application. Authentication : The process of validating the identity of a user. 51. Define caching. Caching is the technique of storing frequently used items in memory so that they can be accessed more quickly. Caching technique allows to store/cache page output or application data on the client on the server. The cached information is used to serve subsequent requests that avoid the overhead of recreating the same information. This enhances performance when same information is requested many times by the user. 52. Define cookie. A cookie is a small file on the client computer that a web application uses to maintain current session information. Cookies are used to identity a user in a future session. 53. What is delegate? A delegate acts like a strongly type function pointer. Delegates can invoke the methods that they reference without making explicit calls to those methods. It is type safe since it holds reference of only those methods that match its signature. Unlike other classes, the delegate class has a signature. Delegates are used to implement event programming model in .NET application.

Delegates enable the methods that listen for an event, to be abstract. 54. Explain Exception handling in .Net. Exceptions or errors are unusual occurrences that happen within the logic of an application. The CLR has provided structured way to deal with exceptions using Try/Catch block. ASP.NET supports some facilities to handling exceptions using events suck as Page_Error and Application_Error. 55. What is impersonation? Impersonation means delegating one user identity to another user. In ASP.NET, the anonymous users impersonate the ASPNET user account by default. You can use <identity> element of web.config file to impersonate user. E.g. <identity impersonate="true"/> 56. What is managed code in .Net? The code that runs under the guidance of common language runtime (CLR) is called managed code. The versioning and registration problem which are formally handled by the windows programming are solved in .Net with the introduction of managed code. The managed code contains all the versioning and type information that the CLR use to run the application. 57. What are Merge modules? Merge modules are the deployment projects for the shared components. If the components are already installed, the modules merge the changes rather than unnecessarily overwrite them. When the components are no longer in use, they are removed safely from the server using Merge modules facility. 58. What is Satellite assembly? Satellite assembly is a kind of assembly that includes localized resources for an application. Each satellite assembly contains the resources for one culture. 59. Define secured sockets layer. Secured Socket Layer (SSL) ensures a secured web application by encrypting the data sent over internet. When an application is using SSL facility, the server generates an encryption key for the session and page is encrypted before it sent. The client browse uses this encryption key to decrypt the requested Web page. 60. Define session in ASP.NET. A session starts when the browser first request a resources from within the application. The session gets terminated when either browser closed down or session time out has been attained. The default time out for the session is 20 minutes. 61. Define Tracing. Tracing is the way to maintain events in an application. It is useful while the application is in debugging or in the testing phase. The trace class in the code is used to diagnose problem. You can use trace messages to your project to monitor events in the released version of the application. The trace class is found in the System.Diagnostics namespace. ASP.NET introduces tracing that enables you to write debug statements in your code, which still remain in the code even after when it is deployed to production servers.

62. Define View State. ASP.NET preserves data between PostBack events using view state. You can save a lot of coding using view state in the web form. ViewState serialize the state of objects and store in a hidden field on the page. It retains the state of server-side objects between PostBacks. It represents the status of the page when submitted to the server. By default, view state is maintained for each page. If you do not want to maintain the ViewState, include the directive <%@ Page EnableViewState="false" %> at the top of an .aspx page or add the attribute EnableViewState="false" to any control. ViewState exist for the life of the current page. 63. What is application domain? It is the process space within which ASP.NET application runs. Every application has its own process space which isolates it from other application. If one of the application domains throws error it does not affect the other application domains. 64. List down the sequence of methods called during the page load. Init() Initializes the page. Load() Loads the page in the server memory. PreRender() - the brief moment before the page is displayed to the user as HTML Unload() runs just after page finishes loading. 65. What is the importance of Global.asax in ASP.NET? The Global.asax is used to implement application and session level events. 66. How to turn off cookies for a page? Cookie.Discard Property when true, instructs the client application not to save the Cookie on the user s hard disk when a session ends. 67. How can you ensure a permanent cookie? Setting Expires property to MinValue and restrict cookie to get expired. 68. What is AutoPostback? AutoPostBack automatically posts the page back to the server when state of the control is changed. 69. Explain login control and form authentication. Login controls encapsulate all the features offered by Forms authentication. Login controls internally use FormsAuthentication class to implement security by prompting for user credentials validating them. 70. What is the use of Web.config file? Following are the setting you can incorporate in web.config file. Database connections Error Page setting Session States Error Handling Security

Trace setting Culture specific setting

71. Explain in what order a destructors is called. Destructors are called in reverse order of constructors. Destructor of most derived class is called followed by its parent s destructor and so on till the topmost class in the hierarchy. 72. What is break mode? What are the options to step through code? Break mode lets you to observe code line to line in order to locate error. VS.NET provides following option to step through code. Step Into Step Over Step Out Run To Cursor Set Next Statement

73. Explain how to retrieve property settings from XML .config file. Create an instance of AppSettingsReader class, use GetValue method by passing the name of the property and the type expected. Assign the result to the appropriate variable. 74. Explain Global Assembly Cache. Global Assembly Cache is the place holder for shared assembly. If an assembly is installed to the Global Assembly Cache, the assembly can be accessed by multiple applications. In order to install an assembly to the GAC, the assembly must have to be signed with strong name. 75. Explain Managed code an Un-managed code. Managed code runs under the safe supervision of common language runtime. Managed code carries metadata that is used by common language runtime to offer service like memory management, code access security, and cross-language accessibility. Unmanaged code doesnt follow CLR conventions and thus, can t take the advantages of .Framework. 76. What is side-by-side execution? This means multiple version of same assembly to run on the same computer. This feature enables to deploy multiple versions of the component. 77. Define Resource Files. Resource files contains non-executable data like strings, images etc that are used by an application and deployed along with it. You can changes these data without recompiling the whole application. 78. Define Globalization and Localization. Globalization is the process of creating multilingual application by defining culture specific features like currency, date and time format, calendar and other issues. Localization is the process of accommodating cultural differences in an application.

79. What is reflection? Reflection is a mechanism through which types defined in the metadata of each module can be accessed. The System.Reflection namespaces contains classes that can be used to define the types for an assembly. 80. Define Satellite Assemblies. Satellite Assemblies are the special kinds of assemblies that exist as DLL and contain culture specific resources in a binary format. They store compiled localized application resources. They can be created using the AL utility and can be deployed even after deployment of the application. Satellite Assemblies encapsulate resources into binary format and thus makes resources lighter and consume lesser space on the disk. 81. What is CAS? CAS is very important part of .Net security system which verifies if particular piece of code is allowed to run. It also determines if piece of code have access rights to run particular resource. .NET security system applies these features using code groups and permissions. Each assembly of an application is the part of code group with associated permissions. 82. Explain Automatic Memory Management in .NET. Automatic memory management in .Net is through garbage collector which is incredibly efficient in releasing resources when no longer in use. 83. Whats the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time its being operated on, a new instance is created. 84. Can you store multiple data types in System.Array? No. 85. Whats the difference between the System.Array.CopyTo() and System.Array.Clone()? The first one performs a deep copy of the array, the second one is shallow. How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods. 86. Whats the .NET datatype that allows the retrieval of data by a unique key? HashTable. 87. Whats class SortedList underneath? A sorted HashTable. 88. Will finally block get executed if the exception had not occurred? Yes.

89. Whats the C# equivalent of C++ catch (), which was a catch-all statement for any possible exception? A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}. 90. Can multiple catch blocks be executed? No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block. 91. Why is it a bad idea to throw your own exceptions? Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project. 92. Whats a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers. 93. Whats a multicast delegate? Its a delegate that points to and eventually fires off several methods. 94. Hows the DLL Hell problem solved in .NET? 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. 95. What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command. 96. What namespaces are necessary to create a localized application? System.Globalization, System.Resources. 97. Whats the difference between // comments, /* */ comments and /// comments? Single-line, multi-line and XML documentation comments. 98. How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with a /doc switch. 99. Whats the difference between <c> and <code> XML documentation tag? Single line code example and multiple-line code example. 100.Is XML case-sensitive? Yes, so <Student> and <student> are different elements.

101.What debugging tools come with the .NET SDK? CorDBG command-line debugger, and DbgCLR graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch. 102.What does the This window show in the debugger? It points to the object thats pointed to by this reference. Objects instance data is shown. What does assert() do? 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. 103.Whats the difference between the Debug class and Trace class? Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds. 104.Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to finetune the tracing activities. 105.Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor. 106.How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger. 107.What are three test cases you should go through in unit testing? Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly). 108.Can you change the value of a variable while debugging a C# application? Yes, if you are debugging via Visual Studio.NET, just go to Immediate window. 109.Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources). 110.What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but its a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines. 111.What is the wildcard character in SQL? 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 would involve La%.

Explain ACID rule of thumb for transactions. Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no inbetween case where something has been updated and something hasnt), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after). 112.What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords). 113.Which one is trusted and which one is untrusted? 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 the transaction. 114.Why would you use untrusted verificaion? Web Services might use it, as well as non-Windows applications. 115.Whats the data provider name to connect to Access database? Microsoft.Access. 116.What does Dispose method do with the connection object? Deletes it from the memory. 117.What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings. -----------------------------118.What are the important principles of SOA (Service oriented Architecture)? WCF is based on SOA. Boundaries are well defined - In SOA, everything is formalized. The client who is consuming the service does not need to know how the implementation of the service is done. If you look at some old methodologies of communication like DCOM. Any changes at server level the client also has to change. Therefore, the server and client implementation was so much bound that changes need to be done at all places. In SOA, the rule is if you do enhancement you do not need to change anything at the client. SOA based application only understands that there is an end point, contract, and bindings. Services evolve - Change is the law of nature and services will evolve. In SOA, services can be versioned and you can host those services in new ends. For instance, you have a service called as Search Tickets (Ticket Number) which gives details based on Ticket Number and its exposed on end point ep1. Tomorrow you want make your Search Tickets service more useful by also providing an extra option of allowing him to search by passenger name. Therefore, you just declare a new end ep2 with service Search Tickets (Ticket Number, Passenger Name). So the client who is consuming the service at end ep1 continues and at the other end, we have evolved our service by adding new ends ep2.

Services share only schemas and contracts - Services use Schemas to represent data and contracts to understand behavior. They do not use language dependent types or classes in order to understand data and behavior. XML is used to define schemas and contracts. Due to this, there is not heavy coupling between environments. Service compatibility is policy based - Policy describes the capabilities of the system. Depending on policies, the service can degrade to match the service for the client. For instance your service needs to be hosted for two types of client one which uses Remoting as the communication methodology while other client uses DCOM. An ideal SOA service can cater to both of them according to their communication policies. 119. What are ends, contract, address, and bindings? These three terminologies on which SOA service stands. Every service must expose one or more ends by which the service can be available to the client. End consists of three important things where, what and how:Contract (What) : Contract is an agreement between two or more parties. It defines the protocol how client should communicate with your service. Technically, it describes parameters and return values for a method. Address (Where) : An Address indicates where we can find this service. Address is a URL, which points to the location of the service. Binding (How) : Bindings determine how this end can be accessed. It determines how communications is done. For instance, you expose your service, which can be accessed using SOAP over HTTP or BINARY over TCP. So for each of these communications medium two bindings will be created. 120.Which specifications does WCF follow? WCF supports specifications defined by WS-* specifications. WS-* specifications are defined together by Microsoft, IBM, SUN and many other big companies so that they can expose there service through a common protocol. WCF supports all specifications defined we will understand them one by one. Messaging (WS-Addressing) :- SOAP is the fundamental protocol for web services. WS Addressing defines some extra additions to SOAP headers, which makes SOAP free from underlying transport protocol. One of the good things about Message transmission is MTOM, also termed as Message Transmission Optimization Mechanism. They optimize transmission format for SOAP messages in XML-Binary formant using XML optimized packaging (XOP). Because the data will sent in binary and optimized format, it will give us huge performance gain. Security (WS-Security, WS-Trust, and WS-Secure Conversation):- All the three WS- define authentication, security, data integrity and privacy features for a service. Reliability (WS-Reliable Messaging):- This specification ensures end-to-end communication when we want SOAP messages to be traversed back and forth many times. Transactions (WS-Coordination and WS-Atomic Transaction):- These two specifications enable transaction with SOAP messages. Metadata (WS-Policy and WS-Metadata exchange):- WSDL is a implementation of WS-Metadata Exchange protocol. WS-Policy defines more dynamic features of a service, which cannot be expressed by WSDL. We have stressed on the WS-* specification as it is a specification which a service has to follow to be compatible with other languages. Because WCF follows WS-* specifications other languages like JAVA , C++ can also exploit features like Messaging , Security , Reliability and transactions written in C# or VB.NET. This is the biggest achievement of WCF to integrate the above features with other languages.

Note: - During interview the interviewer expects that you know what WS-* specification are supported by WCF and its advantages with respect to interacting with other languages. 121.What are the main components of WCF? We need to define three main components in WCF: Service class. Hosting environment End point

122.Explain how Ends, Contract, Address, and Bindings are done in WCF?

123.What is a service class?

124.What is a service contract, operation contract and Data Contract?

125.What are the various ways of hosting a WCF service? There are three major ways to host a WCF service: Self-hosting the service in his own application domain. This we have already covered in the first section. The service comes in to existence when you create the object of Service Host class and the service closes when you call the Close of the Service Host class. Host in application domain or process provided by IIS Server. Host in Application domain and process provided by WAS (Windows Activation Service) Server.

126.How do we host a WCF service in IIS?

127.What are the advantages of hosting WCF Services in IIS as compared to self-hosting? There are two main advantages of using IIS over self-hosting:Automatic activation : IIS provides automatic activation that means the service is not necessary to be running in advance. When any message is received by the service it then launches and fulfills the request. But in case of self hosting the service should always be running. Process recycling : If IIS finds that a service is not healthy that means if it has memory leaks etc, IIS recycles the process. Ok let us try to understand what is recycling in IIS process. For every browser instance, a worker process is spawned and the request is serviced. When the browser disconnects the worker, process stops and you loose all information. IIS also restarts the worker process. By default, the worker process is recycled at around 120 minutes. So why does IIS recycle. By restarting the worker process it ensures any bad code or

memory leak do not cause issue to the whole system. In case of self-hosting both the above features, you will need to code yourself. Lot of work right!!. That is why IIS is the best option for hosting services until you are really doing something custom. Below figure shows where the recycle option is located in IIS. You need to click on the DefaultAppool and then Properties.

128.What are the major differences between services and Web services?

129.What is the difference WCF and Web services? Web services can only be invoked by HTTP. While Service or a WCF component can be invoked by any protocol and any transport type. Second web services are not flexible. However, Services are flexible. If you make a new version of the service then you need to just expose a new end. Therefore, services are agile and which is a very practical approach looking at the current business trends. 130.What are different bindings supported by WCF? WCF includes predefined bindings. They cover most of bindings widely needed in day-to-day application. However, just incase you find that you need to define something custom WCF does not stop you. So let us try to understand what each binding provides. BasicHttpBinding: - This binding is used when we need to use SOAP over HTTP. This binding can also be configured to be used as HTTPS. It can be also configured to send data in plain text or in optimized form like MTOM. Note: - MTOM is discussed in one of the pervious questions in this chapter.

WsHttpBinding: - It is same like BasicHttpBinding. In short, it uses SOAP over HTTP. But with it also supports reliable message transfer, security and transaction. WS-Reliable Messaging, security with WS-Security, and transactions with WS-Atomic Transaction supports reliable message. NetTcpBinding: - This binding sends binary-encoded SOAP, including support for reliable message transfer, security, and transactions, directly over TCP. The biggest disadvantage of NetTcpBinding is that both server and client should be also made in .NET language. NetNamedPipesBinding:-Ths binding Sends binary-encoded SOAP over named pipes. This binding is only usable for WCF-to-WCF communication between processes on the same Windows-based machine. Note: - An interprocess control (IPC) protocol is used for exchanging information between two applications, possibly running on different computers in a network. The difference between Named pipes and TCP is that named pipes have good performance in terms of communication with in processes. But when it comes to communicate across network TCP holds the best choice. So if you are using WCF to communicate with process its the best choice to use in terms for performance. Named pipes do not perform when the traffic is heavy as compared to TCPIP. NetMsmqBinding: - This binding sends binary-encoded SOAP over MSMQ. This binding can only be used for WCF-to-WCF communication. 131.Which are the various programming approaches for WCF? 132.What is one-way operation? 133.Can you explain duplex contracts in WCF? 134.How can we host a service on two different protocols on a single server? 135.How can we use MSMQ bindings in WCF? 136.Can you explain transactions in WCF? 137.What different transaction isolation levels provided in WCF? 138.Can we do transactions using MSMQ? 139.Can we have two-way communications in MSMQ? 140.What are Volatile queues? 141.What are Dead letter queues? 142.What is a poison message?

You might also like