7 latest-dot-net-interview-questions

34,138 views

Published on

Its

2 Comments
6 Likes
Statistics
Notes
  • Visit the following link to learn some commonly asked Interview Questions for the job or vacancy of Software Engineer or Software/Web/Desktop Application Developer. It also includes OOP, C#, ASP.NET, ADO.NET and SQL Interview Questions. http://sohaiby.blogspot.com/2013/09/software-engineerdeveloper-interview.html
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • it s very useful
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
34,138
On SlideShare
0
From Embeds
0
Number of Embeds
278
Actions
Shares
0
Downloads
934
Comments
2
Likes
6
Embeds 0
No embeds

No notes for slide

7 latest-dot-net-interview-questions

  1. 1. LATEST DOT NET INTERVIEW QUESTIONSWhat are Design Patterns?A Design Pattern essentially consists of a problem in a software design and a solution to the same. InDesign Patterns each pattern is described with its name, the motivation behind the pattern and itsapplicability.According to MSDN, "A design pattern is a description of a set of interacting classes that provide aframework for a solution to a generalized problem in a specific context or environment. In other words, apattern suggests a solution to a particular problem or issue in object-oriented software development.Benefits of Design PatternsThe following are some of the major advantages of using Design Patterns in software development.· Flexibility · Adaptability to change · ReusabilityWhen to use Design PatternsDesign Patterns are particularly useful in one of the following scenarios.· When the software application would change in due course of time.· When the application contains source code that involves object creation and event notification.When not to use Design Patterns. Do not use design patterns in any of the following situations.· When the software being designed would not change with time.· When the requirements of the source code of the application are unique.If any of the above applies in the current software design, there is no need to apply design patterns in thecurrent design and increase unnecessary complexity in the design.The Gang of Four (GOF) PatternsThe invention of the design patterns that we commonly use today can be attributed to the following fourpersons: Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. These men invented 23 patterns inall that are commonly known as the Gang of Four patterns or the GOF patterns.· Creational · Structural · BehavioralEach of these groups in turn contains related sub patterns.Creational PatternsThe Creational Patterns deals with the best possible way of creating an object or an instance of a class.They simplify object creation and provide a flexible approach towards object creation. The following are thesub-patterns that fall under this group.· Abstract Factory · Factory · Builder · Prototype · SingletonBoth the Abstract Factory and the Factory pattern have the same intent.
  2. 2. The Singleton Pattern indicates that there can be only one instance of a class throughout the Application’slife cycle. A singleton class is one that can be instantiated only once in the application domain and providesa global point of access to it.Structural PatternsStructural Patterns provides the flexibility to specify how objects and classes can interoperate. The followingare the sub patterns that comprise the Structural Patterns group.· Adapter · Façade · Bridge · Composite· Decorator · Flyweight · Proxy · Adapter· Bridge · Composite · Decorator · Flyweight· ProxyBehavioral PatternsBehavioral patterns help you define a structure for inter-object communication between objects in yoursystem. This design pattern is typically used to monitor the messages that are transmitted when the objectscommunicate in a system. The following are the sub patterns under Behavioral Patterns.· Chain of Responsibility · Command · Interpreter · Iterator· Mediator · Memento · Observer · State· Strategy · Template Method · VisitorASP.NET MVC is a framework that allows developers to apply the MVC pattern in the development of anASP.NET application, thus allowing a better separation of concerns, which results in better reusability andeasier testing.MVC consists of three kinds of objectsThe Model is an application object.The View is the screen presentation.The controller defines the way the user interface reacts to user inputs• The request comes from the client and hits the Controller.• The Controller calls the Model in order to perform some "business" operations. • The Model returns the results of the operations back to the Controller. • The Controller decides which View needs to be rendered and sends it the data that must be rendered. • Finally the View renders the output and sends the response back to the client.What is Cryptography?Cryptography is used to protect data and has many valuable uses. It can protect data from being viewed,modified, or to ensure the integrity from the originator. Cryptography can be used as a mechanism toprovide secure communication over an unsecured network, such as the Internet, by encrypting data, sendingit across the network in the encrypted state, and then the decrypting the data on the receiving end.Encryption can also be used as an additional security mechanism to further protect data such as passwordsstored in a database to prevent them from being human readable or understandable.Encryption Components
  3. 3. Encryption involves the use of a cryptography algorithm combined with a key to encrypt and decrypt thedata. The goal of every encryption algorithm is to make it as difficult as possible to decrypt the data withoutthe proper key. Data is translated from its originating form into something that appears meaningless unlessthe proper algorithm and key are used to decrypt the data.The Microsoft .NET Framework classes (System.Security.Cryptography) will manage the details ofcryptography for you. The classes are implemented with the same interface; so working with the classes isthe same across the cryptography namespace.Public-Key EncryptionPublic-key encryption, also known as asymmetric encryption, uses a public and private key pair to encryptand decrypt data. The public key is made available to anyone and is used to encrypt data to be sent to theowner of the private key. The private key, as the name implies, is kept private. The private key is used todecrypt the data and will only work if the correct public key was used when encrypting the data. The privatekey is the only key that will allow data encrypted with the public key to be decrypted. The keys can bestored for use multiple times, or generated for a one-time use.Asymmetric encryption algorithms are usually efficient for encrypting small amounts of data only. Thefollowing public-key algorithms are available for use in the .NET Framework.Digital Signature Algorithm (DSA)RSAPrivate-Key EncryptionPrivate-key Encryption, also known as symmetric encryption, uses a single key to encrypt and decryptinformation. The key must be kept secret from those not authorized to decrypt the data lest the data becompromised. Private-key algorithms are relatively fast and can be used to encrypt and decrypt largestreams of data. Private-key algorithms are known as block ciphers because they encrypt data one block at atime. A block cipher will encrypt the same input block into the same output block based on the algorithm andkey. If the anything were known about the structure of the data, patterns could be detected and the keycould possibly be reverse engineered. To combat this, the classes in the .NET Framework use a processknown as chaining where information from the previous block is used in encrypting the current block. Thishelps prevent the key from being discovered. It requires an initialization vector (IV) be given to encrypt thefirst block of data.The following private-key algorithms are available in the .NET Framework. Each description contains somebasic information about each algorithm, including the strengths and weaknesses.Data Encryption Standard (DES) algorithm encrypts and decrypts data in 64-bit blocks, using a 64-bit key.Even though the key is 64-bit, the effective key strength is only 56-bits. There are hardware devicesadvanced enough that they can search all possible DES keys in a reasonable amount of time. This makes theDES algorithm breakable, and the algorithm is considered somewhat obsolete.RC2 is a variable key-size block cipher. The key size can vary from 8-bit up to 64-bits for the key. It wasspecifically designed as a more secure replacement to DES. The processing speed is two to three timesfaster than DES. However, the RC2CryptoServiceProvider available in the .NET Framework is limited to 8characters, or a 64-bit key. The 8-character limitation makes it susceptible to the same brute force attack asDES.TripleDES algorithm uses three successive iterations of the DES algorithm. The algorithm uses either two orthree keys. Just as the DES algorithm, the key size is 64-bit per key with an effective key strength of 56-bitper key. The TripleDES algorithm was designed to fix the shortcomings of the DES algorithm, but the threeiterations result in a processing speed three times slower than DES alone.Rijndael algorithm, one of the Advanced Encryption Standard (AES) algorithms, was designed as areplacement for the DES algorithms. The key strength is stronger than DES, and was designed to out
  4. 4. perform DES. The key can vary in length from 128, 192, to 256 bits in length. This is the algorithm Ipersonally trust the most and that Ill use for the examples contained in the column.Hashing AlgorithmsNo, Im not talking about some type of drug related activity or an extra special recipe for brownies. Hashingrefers to mapping data of any length into a fixed-length byte sequence. Regardless of if the input is thecontents of the library of Congress or the typing test "The quick brown fox jumps over the lazy dog" it willresult in an output of the same size. Hashing also produces unique results. Just as no two snowflakes areidentical, no two combinations of input will produce the same hash output. Even if the input varies by asingle character it will produce different output. The .NET Framework provides support for the following hashalgorithms of which Ill leave it up to you to discover which one is right for you based on the size of the datayou require.HMACSHA1 MACTripleDES MD5CryptoServiceProvider SHA1ManagedSHA256Managed SHA384Managed SHA512ManagedHow to Generate a Key and IV for Private-key EncryptionEach algorithm has specific key sizes that it expects for use. Each key must fit a predetermined size typicallyranging from 1 character (8-bit) up to 32 characters (256-bit). Some of the algorithms support varying keysizes, but they must be within the valid ranges of key size for the particular algorithm. For our purposes,well use Rijndael, which supports 128, 192, and 256 bit keys. The way to generate a 128-bit key for use isthrough one of the hashing algorithms. A phrase, or "secret" of any length can be hashed to generate a keyof the required size for encrypting data. The following code outlines a class containing a method that takesan input phrase and generates a key and IV for use.Using Encryption to Protect Sensitive Data Stored in a DatabaseThis brings us to a possible and often overlooked use for encryption, which is encrypting data such aspasswords that are stored in a database. There are several benefits to storing sensitive data such aspasswords in encrypted format.It keeps sensitive application data such as passwords secret from those authorized to view data that ideallyshould not be able to see application specific data such as passwords.It keeps passwords protected from unauthorized access. If the database is somehow compromised, theintruder must now the correct algorithm and key to decrypt the sensitive data.Passing direct input to a query is dangerous because you never know what the input may contain. Suppose astored procedure including something like "WHERE vc_Login = @Login and Password = @Password" is usedfor authentication. A user name of "m or 1=1" with the same for the password could evaluate to a truestatement and result in incorrectly allowing access. If the user id and or password were stored encryptedthen the data would not evaluate to a valid SQL statement because an encrypted form of the statementwould be used in the evaluation.22 New Features of Visual Studio 2008 for .NET Professionals1. LINQ SupportLINQ essentially is the composition of many standard query operators that allow you to work with data in amore intuitive way regardless.The benefits of using LINQ are significant – Compile time checking C# language queries, and the ability todebug step by step through queries.2. Expression Blend Support
  5. 5. Expression blend is XAML generator tool for silverlight applications. You can install Expression blend as anembedded plug-in to Visual Studio 2008. By this you can get extensive web designer and JavaScript tool.3. Windows Presentation FoundationWPF provides you an extensive graphic functionality you never seen these before. Visual Studio 2008contains plenty of WPF Windows Presentation Foundation Library templates. By this a visual developer whois new to .NET, C# and VB.NET can easily develop the 2D and 3D graphic applications.Visual Studio 2008 provides free game development library kits for games developers. currently this gamedevelopment kits are available for C++ and also 2D/3D Dark Matter one image and sounds sets.4. VS 2008 Multi-Targeting SupportEarlier you were not able to working with .NET 1.1 applications directly in visual studio 2005. Now in Visualstudio 2008 you are able to create, run, debug the .NET 2.0, .NET 3.0 and .NET 3.5 applications. You canalso deploy .NET 2.0 applications in the machines which contains only .NET 2.0 not .NET 3.x.5. AJAX support for ASP.NETPreviously developer has to install AJAX control library separately that does not come from VS, but now ifyou install Visual Studio 2008, you can built-in AJAX control library. This Ajax Library contains plenty of richAJAX controls like Menu, TreeView, webparts and also these components support JSON and VS 2008contains in built ASP.NET AJAX Control Extenders.6. JavaScript Debugging SupportSince starting of web development all the developers got frustration with solving javascript errors.Debugging the error in javascript is very difficult. Now Visual Studio 2008 makes it is simpler with javascriptdebugging. You can set break points and run the javaScript step by step and you can watch the localvariables when you were debugging the javascript and solution explorer provides javascript documentnavigation support.7. Nested Master Page SupportAlready Visual Studio 2005 supports nested master pages concept with .NET 2.0, but the problem with thisVisual Studio 2005 that pages based on nested masters cant be edited using WYSIWYG web designer. Butnow in VS 2008 you can even edit the nested master pages.8. LINQ Intellisense and Javascript Intellisense support for silverlight applicationsMost happy part for .NET developers is Visual Studio 2008 contains intellisense support for javascript.Javascript Intellisense makes developers life easy when writing client side validation, AJAX applications andalso when writing Silverlight applicationsIntellisense Support: When we are writing the LINQ Query VS provides LINQ query syntax as tool tips.9. Organize Imports or UsingsWe have Organize Imports feature already in Eclipse. SInce many days I have been waiting for this featureeven in VS. Now VS contains Organize Imports feature which removes unnecessary namespaces which youhave imported. You can select all the namespaces and right click on it, then you can get context menu withOrganize imports options like "Remove Unused Usings", "Sort Usings", "Remove and Sort". Refactoringsupport for new .NET 3.x features like Anonymous types, Extension Methods, Lambda Expressions.10. Intellisense FilteringEarlier in VS 2005 when we were typing with intellisense box all the items were being displayed. Forexample If we type the letter K then intellisense takes you to the items starts with K but also all otheritems will be presented in intellisense box. Now in VS 2008 if you press K only the items starts with K willbe filtered and displayed.
  6. 6. 11. Intellisense Box display positionEarlier in some cases when you were typing the an object name and pressing . (period) then intellisense wasbeing displayed in the position of the object which you have typed. Here the code which we type will go backto the dropdown, in this case sometimes programmer may disturb to what he was typing. Now in VS 2008 Ifyou hold the Ctrl key while the intellisense is dropping down then intellisense box will become semi-transparent mode.12. Visual Studio 2008 Split ViewVS 205 has a feature show both design and source code in single window. but both the windows tileshorizontally. In VS 2008 we can configure this split view feature to vertically, this allows developers to usemaximum screen on laptops and wide-screen monitors.Here one of the good feature is if you select any HTML or ASP markup text in source window automaticallycorresponding item will be selected in design window.13. HTML JavaScript warnings, not as errors:VS 2005 mixes HTML errors and C# and VB.NET errors and shows in one window. Now VS 2008 separatesthis and shows javascript and HTML errors as warnings. But this is configurable feature.14. Debugging .NET Framework Library Source Code:Now in VS 2008 you can debug the source code of .NET Framework Library methods. Lets say If you want todebug the DataBind() method of DataGrid control you can place a debugging point over there and continuewith debug the source code of DataBind() method.15. In built Silverlight LibraryEarlier we used to install silverlight SDK separately, Now in VS 2008 it is inbuilt, with this you can create,debug and deploy the silverlight applications.16. Visual Studio LINQ DesignerAlready you know in VS 2005 we have inbuilt SQL Server IDE feature. by this you no need to use any othertools like SQL Server Query Analyzer and SQL Server Enterprise Manger. You have directly databaseexplorer by this you can create connections to your database and you can view the tables and storedprocedures in VS IDE itself. But now in VS 2008 it has View Designer window capability with LINQ-to-SQL.17. Inbuilt C++ SDKEarlier It was so difficult to download and configure the C++ SDK Libraries and tools for developing windowsbased applications. Now it is inbuilt with VS 2008 and configurable18. Multilingual User Interface Architecture - MUIMUI is an architecture contains packages from Microsoft Windows and Microsoft Office libraries. Thissupports the user to change the text language display as he wish.Visual Studio is now in English, Spanish, French, German, Italian, Chinese Simplified, Chinese Traditional,Japanese, and Korean. Over the next couple of months. Microsoft is reengineering the MUI which supportsnine local languages then you can even view Visual studio in other 9 local languages.19. Microsoft Popfly SupportMicrosoft Popfly explorer is an add-on to VS 2008, by this directly you can deploy or hosting the Silverlightapplications and Marshup objectsDeployment Options Supported by .NETYou can deploy an ASP.NET Web application using any one of the following three deployment options.
  7. 7. XCOPY DeploymentUsing the Copy Project option in VS .NETDeployment using VS.NET installerXCOPY DeploymentBefore looking at how .NET enables XCOPY deployment, let us take a moment to understand what XCOPYdeployment is. Prior to .NET, installing a component (for example, a COM Component) required copying thecomponent to appropriate directories, making appropriate registry entries, and so on. But now in .NET, toinstall the component all you need to do is copy the assembly into the bin directory of the client applicationand the application can start using it right away because of the self-describing nature of the assembly. Thisis possible because compilers in the .NET Framework embed identifiers or meta-data into compiled modulesand the CLR uses this information to load the appropriate version of the assemblies. The identifiers containall the information required to load and run modules, and also to locate all the other modules referenced bythe assembly. It is also refered to as zero-impact install since the machine is not impacted by way ofconfiguring the registry entries and configuring the component. This zero-impact install also makes itpossible to uninstall a component without impacting the system in any manner. All that is required tocomplete uninstallation is the removal of specific files from the specific directory. For performing this type ofdeployment, all you need to do is to go to the Command Prompt and copy over the required files to aspecific directory on the server using the XCOPY command.As you can see, the XCOPY command takes a number of arguments./ E - This option copies directories, subdirectories, and files of the source argument, including empty ones./ K - This option allows you to retain all the existing file and folder attributes. When you use XCOPY to copyfiles or a directory tree structure, XCOPY strips off file attributes by default. For example, if a file had theread-only attribute set, that attribute would be lost after the file is copied. To retain the original attributeswith the copied files, you must use the / K parameter./ R - This option overwrites files marked as read only./ O - This option preserves all security-related permission ACLs of the file and folders./ H - This option copies both hidden and system files./ I - This option tells XCOPY to assume that the destination is a directory and create it if it does not alreadyexist.Once the folder is copied over to the target server, you then need to create a virtual directory on the targetserver (using Internet Information Manager MMC snap-in) and map that virtual directory to the physicaldirectory that is created using the XCOPY command. Thats all there is to deploying an ASP.NET Webapplication on a remote server using XCOPY Deployment.Using the Copy Project Option in VS .NETThe Copy Project option in VS .NET makes it very easy to deploy ASP.NET Web applications onto the targetservers. Using this option, you can copy the Web project to the same server or to a different server.If you are using VS .NET to develop Web applicatons, the first thing that you need to do before packaging anASP.NET Web applications is to change the Active Solution Configuration from Debug to Release as shownbelow. This allows the compiler not only to optimize the code but also remove the debugging relatedsymbols from the code, making the code run much faster. To bring up the Configuration Manager, selectyour Web project from the Solution Explorer and select Project->Properties->Configuration Properties fromthe menu and then click on the Configuration Manager Command button. In the Active SolutionConfiguration combo box, select the Release option.To copy the Web project onto the target server, select Project->Copy Project from the menu. Selecting thatoption will result in the following dialog box being displayed.The Copy Project dialog provides the following options.Destination Project Folder: Using this option, you can specify the location to which you want to copy theproject. The location can be the same server or a remote server.Web access method: The Web access method option determines the access method that is used to copy theWeb project to the destination folder. There are two types of Web access methods.File share: This option indicates that you want to directly access your project files on the Web server througha file share. It does not require FrontPage Server Extensions on the server.
  8. 8. FrontPage: This option specifies that you want to use the HTTP-based FrontPage Server Extensions totransfer your project files to the server. Before using this option, make sure FrontPage Server Extensions areinstalled on the server. This option will automatically create the required virtual directory on the targetserver.Copy: The Copy option provides three types:Only files needed to run this application: this option copies built output files (DLLs and references from thebin folder) and any content files (such as .aspx, .asmx files). Most of the time, you should be able to deploythe application using this default option.All project files: this option copies built outputs (DLLs and references from the bin folder) and all files thatare in the project. This includes the project file and source files.All Files in the source project folder: choosing this option will result in all the project files and any other filesthat are in the project folder (or subfolder) being transferred to the destination folder.To copy the Web project, select the appropriate options from the above Copy Project dialog box and clickOK. This will result in the ASP.NET Web application being deployed on the target server.Deployment Using VS .NET Web Setup ProjectEven though XCOPY deployment and Copy Project options are very simple and easy-to-use, they do not lendthemselves well to all of the deployment needs. For example, if your application requires more robustapplication setup and deployment requirements, VS .NET installer can be the right choice. Although you candistribute your Web application as a collection of build outputs, installer classes, and database creationscripts, it is often easier to deploy complex solutions with Windows Installer files. VS .NET provides Websetup projects that can be used to deploy Web applications. These Web setup projects differ from standardsetup projects in that they install Web applications to a virtual root folder on a Web server rather than in theProgram Files folder, as is the case with the applications installed using standard setup projects.Since VS .NET installer is built on top of Windows Installer technology, it also takes advantages of WindowsInstaller features. Before starting on a discussion of VS .NET Web Setup Project, let us understand thearchitecture of Windows Installer technology that provides the core foundation on top of which the VS .NETinstaller is built.Features Provided by VS .NET Web Setup ProjectThe deployment project in VS .NET builds on features of the Windows installer by allowing us to perform thefollowing operations.Reading or writing of registry keysCreating directories in the Windows file system on the target serversProvides a mechanism to register componentsProvides a way to gather information from the users during installationAllows you to set launch conditions, such as checking the user name, computer name, current operatingsystem, software application installed, presence of .NET CLR and so on.Also makes it possible to run a custom setup program or script after the installation is complete.In the next section, we will see how to deploy our DeploymentExampleWebApp using the VS .NET WebSetup Project.Creating a Web Setup Project Using VS .NET InstallerWe will start by adding a new Web Setup Project to our DeploymentExampleWebApp ASP.NET Webapplication solution by selecting File->Add Project-> New Project from the menu. In the New Project dialogbox, select Setup and Deployment Projects from the Project Types pane and then select Web Setup Projectin the Templates pane as shown in the following figure.After creating the project, you then need to add the output of the primary assembly and the content files ofthe ASP.NET Web application to the setup project. To do this, right click on theDeploymentExampleWebAppSetup project in the solution explorer and select Add->Project Output from thecontext menu. In the Add Project Output Group dialog box, select DeploymentExampleWebApp from theProject combo box and select Primary Output from the list.
  9. 9. After adding the project output, you then need to add the related Content Files (such as .aspx files, Images,and so on) to the project. To do this, again bring up the Add Project Output dialog box and then selectContent Files from the list this time. It is illustrated in the following screenshot.After adding the Primary output and the Content Files to the Web Setup project, the solution explorer looksas follows:Configuring Properties through the Properties WindowThere are a number of properties that you can set through the properties window of the Web Setup project.These properties determine the runtime display and behavior of the Windows installer file. To accomplishthis, right click on the DeploymentExampleWebAppSetup project from the solution explorer and selectProperties from the context menu to bring up its properties window. The dialog box shown below appears inthe screen.As can be seen from the above screenshot, the properties window provides properties such as Author,Description, Manufacturer, Support Phone and so on that can be very useful to the users (who are installingyour application) of your application to get more details about your application.Installing the ASP.NET Web ApplicationOnce you have created the Windows installer file (.msi file), then installing the ASP.NET application in thetarget servers is very straightforward. All you need to do is to double-click on the .msi file from the Windowsexplorer. This will initiate the setup wizard, which will walk you through the installation steps. The followingscreenshot shows the first dialog box displayed during the installation.Clicking on Next in the above dialog box results in the following dialog box, where you can specify the virtualdirectory that will be used to host this Web application. This is one of the handy features wherein thecreation of virtual directory is completely automated obviating the need for manual intervention. In part twoof this article, we will see how to set specific properties (such as Directory Security, Default Document andso on) on the virtual directory as part of the installation process.In the above dialog box, you can also click on the Disk Cost... command button to get an idea of the spacerequired for installing this Web application. Clicking on Next in the above dialog box results in the followingdialog box where you are asked to confirm the installation.When you click on Next in the above dialog box, the installation will begin and the application will beinstalled. If the application is successfully installed, you will see the following dialog box.After installing the application, you can see the installed ASP.NET application through the Add/RemovePrograms option (that can be accessed through Start->Settings->Control Panel) in your computer. Fromhere, you can run the setup program to uninstall the application any time you want to. CachingThe ability to store data in the main memory and then allow for retrieval of the same as and when they arerequested.Caching is a technique of persisting the data in memory for immediate access to requesting program calls.ASP.NET supports three types of caching for Web-based applications: 1. Page Level Caching (called Output Caching) 2. Page Fragment Caching (often called Partial-Page Output Caching) 3. Programmatic or Data CachingOutput CachingOutput caching caches the output of a page (or portions of it) so that a pages content need not begenerated every time it is loaded.In a typical ASP.NET page, every time the user views the page, the Web server will have to dynamicallygenerate the content of the page and perform the relevant database queries (which are a very expensivetask to do).
  10. 10. Considering the fact that the page does not change for a certain period of time, it is always a good idea tocache whatever is non-static so that the page can be loaded quickly.In Page Output Caching, the entire page is cached in memory so all the subsequent requests for the samepage are addressed from the cache itself.In Page Fragment Caching, a specific a portion of the page is cached and not the entire page. Page Output orFragment Caching can be enabled or disabled at the Page, Application or even the Machine levels.Data Caching allows us to cache frequently used data and then retrieve the same data from the cache asand when it is needed. We can also set dependencies so that the data in the cache gets refreshed wheneverthere is a change in the external data store. The external data store can be a file or even a database.Accordingly, there are two types to dependencies, namely, file based and Sql Server based. There are alsodiffering cache expiration policiesSyntax: <%@ OutputCache Duration="60" VaryByParam="none" %>The above syntax specifies that the page be cached for duration of 60 seconds and the value "none" forVaryByParam* attribute makes sure that there is a single cached page available for this duration specified.* VaryByParam can take various "key" parameter names in query string. Also there are other attributes likeVaryByHeader, VaryByCustom etc.The following is the complete syntax of page output caching directive in ASP.NET.<%@ OutputCache Duration="no of seconds"Location="Any | Client | Downstream | Server | None"VaryByControl="control"VaryByCustom="browser |customstring"VaryByHeader="headers"VaryByParam="parameter" %>To store the output cache for a specified durationDeclarative Approach:<%@ OutputCache Duration="60" VaryByParam="None" %>Programmatic Approach:Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));Response.Cache.SetCacheability(HttpCacheability.Public);• To store the output cache on the browser client where the request originatedDeclarative Approach:<%@ OutputCache Duration="60" Location="Client" VaryByParam="None" %>Programmatic Approach:Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));Response.Cache.SetCacheability(HttpCacheability.Private);• To store the output cache on any HTTP 1.1 cache-capable devices including the proxy serversand the client that made requestDeclarative Approach:<%@ OutputCache Duration="60" Location="Downstream" VaryByParam="None" %>Programmatic Approach:
  11. 11. Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));Response.Cache.SetCacheability(HttpCacheability.Public);Response.Cache.SetNoServerCaching();• To store the output cache on the Web serverDeclarative Approach:<%@ OutputCache Duration="60" Location="Server" VaryByParam="None" %>Programmatic Approach:TimeSpan freshness = new TimeSpan(0,0,0,60);DateTime now = DateTime.Now;Response.Cache.SetExpires(now.Add(freshness));Response.Cache.SetMaxAge(freshness);Response.Cache.SetCacheability(HttpCacheability.Server);Response.Cache.SetValidUntilExpires(true);• To cache the output for each HTTP request that arrives with a different City:Declarative Approach:<%@ OutputCache duration="60" varybyparam="City" %>Programmatic Approach:Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));Response.Cache.SetCacheability(HttpCacheability.Public);Response.Cache.VaryByParams["City"] = true;For the VaryByCustom attribute, the VaryByHeader attribute, and the VaryByParam attribute in the @OutputCache directive, the HttpCachePolicy class provides the VaryByHeaders property and theVaryByParamsproperty, and the SetVaryByCustom method.1. Page Output CachingIn Page Output Caching, the entire page is cached in memory so all the subsequent requests for the samepage are addressed from the cache itself.Partial-Page Output Caching/ Page Fragment CachingIn Page Fragment Caching, a specific a portion of the page is cached and not the entire page. Page Output orFragment Caching can be enabled or disabled at the Page, Application or even the Machine levels.More often than not, it is impractical to cache entire pages. For example, you may have some content onyour page that is fairly static, such as a listing of current inventory, but you may have other information,such as the users shopping cart, or the current stock price of the company, that you wish to not be cachedat all. Since Output Caching caches the HTML of the entire ASP.NET Web page, clearly Output Cachingcannot be used for these scenarios: enter Partial-Page Output Caching.Partial-Page Output Caching, or page fragment caching, allows specific regions of pages to be cached.fragment caching comes from the attribute "VaryByControl". Using this attribute one can cache a usercontrol based on the properties exposed.Syntax: <%@ OutputCache Duration="60" VaryByControl="DepartmentId" %>The above syntax when declared within an *.ascx file ensures that the control is cached for 60 seconds andthe number of representations of cached control is dependant on the property "DepartmentId" declared inthe control.
  12. 12. Data CachingProgrammatic or data caching takes advantage of the .NET Runtime cache engine to store any data or objectbetween responses. That is, you can store objects into a cache, similar to the storing of objects inApplication scope in classic ASP.Realize that this data cache is kept in memory and "lives" as long as the host application does. In otherwords, when the ASP.NET application using data caching is restarted, the cache is destroyed and recreated.Data Caching is almost as easy to use as Output Caching or Fragment caching: you simply interact with it asyou would any simple dictionary object.Note that the Insert method allows you to simply add items to the cache using a key and value notation aswell. For example to simply add an instance of the object bar to the cache named foo, use syntax like this:Cache.Insert("foo", bar); // C#Cache.Insert("foo", bar) VB.NETQuestion - Define Caching in ASP.NET.Answer - Caching technique allows to store/cache page output or application data on the client. The cachedinformation is used to serve subsequent requests that avoid the overhead of recreating the sameinformation. This enhances performance when same information is requested many times by the user.Question - Advantages of CachingAnswer - It increases performance of the application by serving user with cached output.It decreases server round trips for fetching data from database by persisting data in the memory.It greatly reduces overhead from server resources.Question - What are the types of Caching in ASP.NET?Answer - Caching in ASP.NET can be of the following typesPage Output CachingPage Fragment CachingData CachingQuestion - Explain in brief each kind of caching in ASP.NET.Answer - Page Output CachingThis type of caching is implemented by placing OutputCache directive at the top of the .aspx page at designtime.For example:<%@OutputCache Duration= "30" VaryByParam= "DepartmentId"%>The duration parameter specifies for how long the page would be in cache and the VaryByParam parameteris used to cache different version of the page.The VaryByParam parameter is useful when we require caching a page based on certain criteria.Page Fragment CachingThis technique is used to store part of a Web form response in memory by caching a user control.Data CachingData Caching is implemented by using Cache object to store and quick retrieval of application data.Cache object is just like application object which can be access anywhere in the application.The lifetime of the cache is equivalent to the lifetime of the application.Question:-What do you mean by Share Point Portal ?Answer: Here I have taken information regarding Share Point Portal Server 2003 provides mainly access tothe crucial business information and applications. With the help of Share Point Server we can serverinformation between Public Folders, Data Bases, File Servers and the websites that are based on Windowsserver 2003. This Share Point Portal is integrated with MSAccess and Windows servers, So we can get aWide range of document management functionality. We can also create a full featured portal withreadymade navigation and structure.
  13. 13. Question:-What is cross page posting in ASP.NET2.0 ?Answer: When we have to post data from one page to another in application we used server.transfermethod but in this the URL remains the same but in cross page posting there is little different there isnormal post back is done but in target page we can access values of server control in the source page.This isquite simple we have to only set the PostBackUrl property of Button,LinkButton or imagebutton whichspecifies the target page. In target page we can access the PreviousPage property. and we have to use the@PreviousPageType directive. We can access control of PreviousPage by using the findcontrol method. Whenwe set the PostBackURL property ASP.NET framework bind the HTML and Javascript function automatically.Question: How to start Outlook,NotePad file in AsP.NET with code ?Answer: Here is the syntax to open outlook or notepad file in ASP.NET VB.NETProcess.Start("Notepad.exe") Process.Start("msimn.exe"); C#.NETSystem.Diagnostics.Process.Start("msimn.exe"); System.Diagnostics.Process.Start("Notepad.exe");Question: What is the purpose of IIS ?Answer: We can call IIS(Internet Information Services) a powerful Web server that helps us creating highlyreliable, scalable and manageable infrastructure for Web application which runs on Windows Server 2003.IIS helps development center and increase Web site and application availability while lowering systemadministration costs. It also runs on Windows NT/2000 platforms and also for above versions. With IIS,Microsoft includes a set of programs for building and administering Web sites, a search engine, and supportfor writing Web-based applications that access database. IIS also called http server since it process the httprequest and gets http response.Question: What is main difference between GridLayout and FormLayout ?Answer: GridLayout helps in providing absolute positioning of every control placed on the page. It is easierto develop page with absolute positioning because control can be placed any where according to ourrequirement. But FormLayout is little different only experience Web Developer used this one reason is it ishelpful for wider range browser. If there is absolute positioning we can notice that there are number of DIVtags. But in FormLayout whole work are done through the tables.Question: How Visual SourceSafe helps Us ?Answer: One of the powerful tool provided by Microsoft to keep up-to-date of files system its keeps recordsof file history once we add files to source safe it can be add to database and the changes ads by differentuser to this files are maintained in database from that we can get the older version of files to. This also helpsin sharing,merging of files.Question:-Can you define what is SharePoint and some overview about this ?Answer: SharePoint helps workers for creating powerful personalized interfaces only by dragging and droppre-defined Web Part Components. And these Web Parts components also helps non programmers to getinformation which care and customize the appearance of Web pages. To under stand it we take an example one Web Part might display a users information another might create a graph showing current employeestatus and a third might show a list of Employees Salary. This is also possible that each functions has a linkto a video or audio presentation. So now Developers are unable to create these Web Part components andmake them available to SharePoint users.Question:-What is different between WebUserControl and in WebCustomControl ?Answer: Web user controls :- Web User Control is Easier to create and another thing is that its support islimited for users who use a visual design tool one good thing is that its contains static layout one more thinga separate copy is required for each application.Web custom controls:-Web Custom Control is typical to create and good for dynamic layout and anotherthing is it have full tool support for user and a single copy of control is required because it is placed in GlobalAssembly cache.Question:-What is Sandbox in SQL server and explain permission level in Sql Server ?Answer: Sandbox is place where we run trused program or script which is created from the third party.There are three type of Sandbox where user code run.Safe Access Sandbox:-Here we can only create stored procedure,triggers,functions,datatypes etc.But wedoesnot have acess memory ,disk etc.External Access Sandbox:-We cn access File systems outside the box. We can not play withthreading,memory allocation etc.Unsafe Access Sandbox:-Here we can write unreliable and unsafe code.
  14. 14. Question:-How many types of cookies are there in .NET ?Answer: Two type of cookeies.a) single valued eg request.cookies(”UserName”).value=”dotnetquestion”b)Multivalued cookies. These are used in the way collections are used examplerequest.cookies(”CookiName”)(”UserName”)=”dotnetquestionMahesh”request.cookies(”CookiName”)(”UserID”)=”interview″Question: When we get Error HTTP 502 Proxy Error ?Answer: We get this error when we execute ASP.NET Web pages in Visual Web Developer Web server,because the URL randomly select port number and proxy servers did not recognize the URL and return thiserror. To resolve this problem we have to change settings in Internet Explorer to bypass the proxy server forlocal addresses, so that the request is not sent to the proxy.Question:-What do you mean by three-tier architecture?Answer: The three-tier architecture was comes into existence to improve management of code and contentsand to improve the performance of the web based applications. There are mainly three layers in three-tierarchitecture. the are define as follows(1)Presentation(2)Business Logic(3)Database(1)First layer Presentation contains mainly the interface code, and this is shown to user. This code couldcontain any technology that can be used on the client side like HTML, JavaScript or VBScript etc.(2)Second layer is Business Logic which contains all the code of the server-side .This layer have code tointeract with database and to query, manipulate, pass data to user interface and handle any input from theUI as well.(3)Third layer Data represents the data store like MS Access, SQL Server, an XML file, an Excel file or evena text file containing data also some additional database are also added to that layers.Question: What is Finalizer in .NET define Dispose and Finalize?Answer: We can say that Finalizer are the methods thats helps in cleanp the code that is executed beforeobject is garbage collected .The process is called finalization . There are two methods of finalizer Disposeand Finalize .There is little diffrenet between two of this method .When we call Dispose method is realse all the resources hold by an object as well as all the resorces hold bythe parent object.When we call Dispose method it clean managed as well as unmanaged resources.Finalize methd also cleans resources but finalize call dispose clears only the unmanged resources because infinalization the garbase collecter clears all the object hold by managed code so finalization fails to preventthos one of methd is used that is: GC.SuppressFinalize.Question: What is late binding ?Answer: When code interacts with an object dynamically at runtime .because our code literally doesnot carewhat type of object it is interacting and with the methods thats are supported by object and with themethods thats are supported by object .The type of object is not known by the IDE or compiler ,noIntellisense nor compile-time syntax checking is possible but we get unprecedented flexibilty in exchange.ifwe enable strict type checking by using option strict on at the top of our code modules ,then IDE andcompiler will enforce early binding behaviour .By default Late binding is done.Question:-Does .NET CLR and SQL SERVER run in different process?Answer: Dot Net CLR and all .net realtes application and Sql Server run in same process or we can say thatthat on the same address because there is no issue of speed because if these two process are run indifferent process then there may be a speed issue created one process goes fast and other slow may createthe problem.Question: The IHttpHandler and IHttpHandlerFactory interfaces ?Answer: The IHttpHandler interface is implemented by all the handlers. The interface consists of oneproperty called IsReusable. The IsReusable property gets a value indicating whether another request can usethe IHttpHandler instance. The method ProcessRequest() allows you to process the current request. This isthe core place where all your code goes. This method receives a parameter of type HttpContext using whichyou can access the intrinsic objects such as Request and Response. The IHttpHandlerFactory interface
  15. 15. consists of two methods - GetHandler and ReleaseHandler. The GetHandler() method instantiates therequired HTTP handler based on some condition and returns it back to ASP.NET. The ReleaseHandler()method allows the factory to reuse an existing handler.Question: what is Viewstate?Answer:View state is used by the ASP.NET page framework to automatically save the values of the pageand of each control just prior to rendering to the page. When the page is posted, one of the first tasksperformed by page processing is to restore view state.State management is the process by which you maintain state and page information over multiple requestsfor the same or different pages.Client-side options are:* The ViewState property * Query strings * Hidden fields * CookiesServer-side options are:* Application state * Session state * DataBaseUse the View State property to save data in a hidden field on a page. Because ViewState stores data on thepage, it is limited to items that can be serialized. If you want to store more complex items in View State, youmust convert the items to and from a string.ASP.NET provides the following ways to retain variables between requests:Context.Handler object Use this object to retrieve public members of one Web form’s class from asubsequently displayed Web form.Query strings Use these strings to pass information between requests and responses as part of the Webaddress. Query strings are visible to the user, so they should not contain secure information such aspasswords.Cookies Use cookies to store small amounts of information on a client. Clients might refuse cookies, so yourcode has to anticipate that possibility.View state ASP.NET stores items added to a page’s ViewState property as hidden fields on the page.Session state Use Session state variables to store items that you want keep local to the current session(single user).Application state Use Application state variables to store items that you want be available to all users ofthe application.Describe the security authentication flow and process in ASP.NET?When a user requests a web page, there exists a process of security too, so that every anonymous user ischecked for authentication before gaining access to the webpage. The following points are followed in thesequence for authentication when a client attempts a page request: • A .aspx web page residing on an IIS web server is requested by an end user • IIS checks for the users credentials • Authentication is done by IIS. If authenticated, a token is passed to the ASP.NET worker process along with the request • Based on the authentication token from IIS, and on the web.config settings for the requested resource, ASP.NET impersonates the end user to the request thread. For impersonation, the web.config impersonate attributes value is checked.What is Authentication? What are the different types of Authentication?In a client-server environment, there are plenty of cases where the server has to interact and identify theclient that sends a request to the server. Authentication is the process of determining and confirming theidentity of the client.If a client is not successfully identified, it is said to be anonymous.Windows Authentication Forms Authentication Passport AuthenticationEssentially the Windows Authentication and Forms Authentication are the famous ones, as PassportAuthentication is related to a few websites (like microsoft.com, hotmail.com, msn.com etc. only).
  16. 16. Windows Authentication is implemented mostly in Intranet scenarios. When a browser (client) sends aRequest to a server where in windows authentication has been implemented, the initial request isanonymous in nature. The server sends back a Response with a message in HTTP Header. This Prompts aWindow to display a Modal Dialog Box on the browser, where the end user may enter the "User name" and"Password".The end user enters the credentials, which are then validated against the User Store on the Windows server.Note that each user who access the Web Application in a Windows Authentication environment needs to havea Windows Account in the company network.How to avoid or disable the modal dialog box in a Windows Authentication environment?By enabling the Windows Integrated Authentication checkbox for the web application through settings in IIS.Forms Authentication is used in Internet based scenarios, where its not practical to provide a Windows basedaccount to each and every user to the Web Server. In a Forms Authentication environment, the user enterscredentials, usually a User Name and a corresponding Password, which is validated against a UserInformation Store, ideally a database table.Forms Authentication Ticket is the cookie stored on the users computer, when a user is authenticated. Thishelps in automatically logging in a user when he/she re-visits the website. When a Forms Authenticationticket is created, when a user re-visits a website, the Forms Authentication Ticket information is sent to theWeb Server along with the HTTP Request.Describe the Provider Model in ASP.NET 2.0?The Provider model in ASP.NET 2.0 is based on the Provider Design Pattern that was created in the year2002 and later implemented in the .NET Framework 2.0.The Provider Model supports automatic creation of users and their respective roles by creating entries ofthem directly in the SQL Server (May even use MS Access and other custom data sources). So actually, thismodel also supports automatically creating the user tables schema.The Provider model has 2 security providers in it: Membership provider and Role Provider. The membershipprovider saves inside it the user name (id) and corresponding passwords, whereas the Role provider storesthe Roles of the users.For SQL Server, the SqlMembershipProvider is used, while for MS Access, the AccessMembershipProvider isused. The Security settings may be set using the website adminstration tool. Automatically, theAccessMembershipProvider creates a Microsoft Access database file named aspnetdb.mdb inside theapplications App_Data folder. This contains 10 tables.Describe the Personalization in ASP.NET 2.0?ASP.NET 2.0 Personalization - Personalization allows information about visitors to be persisted on a datastore so that the information can be useful to the visitor when they visit the site again. In ASP.NET 2.0, thisis controlled by a Personalization API. Before the Personalization Model came into existence, the priorversions of ASP.NET used of the old Session object to take care of re-visits. Now comes the Profile object.In order to use a Profile object, some settings need to be done in web.config. The example below shallexplain how to use a profile object://Add this to System.Web in web.config<profile><properties> <add name="FirstName" type="System.String"/></properties></profile>In Page_Load event, add the following...If Profile.FirstName <> "" Then
  17. 17. Panel1.Visible = False Response.Write("Welcome Back Dear :, " & Profile.FirstName & ", " & Profile.LastName)Else Panel1.Visible = TrueEnd IfHere is the code how to save the profile properties in an event to save itProfile.FirstName = txtFirstName.TextExplain about Generics?Generics are not a completely new construct; similar concepts exist with other languages. For example, C++templates can be compared to generics. However, theres a big difference between C++ templates and .NETgenerics. With C++ templates the source code of the template is required when a template is instantiatedwith a specific type. Contrary to C++ templates, generics are not only a construct of the C# language;generics are defined with the CLR. This makes it possible to instantiate generics with a specific type in VisualBasic even though the generic class was defined with C#.Why we use Serialization?Serialization of data using built-in .NET support makes persistence easy and reusable.Most uses of serialization fall into two categories: persistence and data interchange. Persistence allowsus to store the information on some non-volatile mechanism for future use. This includes multiple uses ofour application, archiving, and so on. Data interchange is a bit more versatile in its uses. If our applicationtakes the form of an N-tier solution, it will need to transfer information from client to server, likely using anetwork protocol such as TCP. To achieve this we would serialize the data structure into a series of bytesthat we can transfer over the network. Another use of serialization for data interchange is the use of XMLserialization to allow our application to share data with another application altogether. As you can see,serialization is a part of many different solutions within our application.What is Serialization?Serialization is the process of converting an object, or group of objects, into a form that can be persisted.When u serialize an object, you also serialize the values of its properties.How Do You Use Serialization?Serialization is handled primarily by classes and interfaces in the System.Runtime.Serializationnamespace. To serialize an object, you need to create two things: • A stream to contain the serialized objects. • A formatter to serialize the objects into the stream.The Role of Formatters in .NET SerializationA formatter is used to determine the serialized format for objects. All formatters expose the IFormatterinterface, and two formatters are provided as part of the .NET framework: • BinaryFormatter provides binary encoding for compact serialization to storage, or for socket-based network streams. The BinaryFormatter class is generally not appropriate when data must be passed through a firewall. • SoapFormatter provides formatting that can be used to enable objects to be serialized using the SOAP protocol. The SoapFormatter class is primarily used for serialization through firewalls or among diverse systems. The .NET framework also includes the abstract Formatter class that may be used as a base class for custom formatters. This class inherits from the IFormatter interface, and all IFormatter properties and methods are kept abstract, but you do get the benefit of a number of helper methods that are provided for you.

×