Interview questions for ASP.Net 4
Q. What is new with ASP.Net 4 WebForms ?
Ans. Some of the Features are:
. Ability to Set Metatags.
. More control over view state.
. Added and Updated browser definition files.
. ASP.Net Routing.
. The ability to Persist Selected rows in data Control.
. More control over rendered HTML in FormView and ListView Controls.
. Filtering Support for datasource Controls.
ASP.Net 4.0 has many improvements from previous versions such as
- Web.config File Refactoring
- Extensible Output Caching
- Auto-Start Web Applications
- Permanently Redirecting a Page by introducing a new method RedirectPermanent()
- Shrinking Session State to shrink session data
- Extensible Request Validation to avoid cross-site scripting (XSS) attacks by adding custom request-validation logic.
- Object Caching and Object Caching Extensibility by introducing a new assembly "System.Runtime.Caching.dll"
ASP.Net 4.0 also introduced many new features such as
- jQuery Included with Web Forms and MVC: Built in JQuery support
- Content Delivery Network Support: Enables you to easily add ASP.NET Ajax and jQuery scripts to your Web applications. We can refence JQuery script over http like <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js" >
- New Meta tags under HTML Head tag
- Enabling View State for Individual Controls
- Extended Browser Capabilities
- ASP.NET Chart Control to create visually compelling charts for complex statistical or financial analysis
- New Field Templates for URLs and E-mail Addresses
How is Caching extended in asp.Net 4.0?
OutPut Cache in earlier versions of ASP.Net has a limitation - generated content always has to be stored in memory, and on servers that are experiencing heavy traffic, the memory consumed by output caching can compete with memory demands from other portions of a Web application.
ASP.NET 4 adds an extensibility point to output caching that enables you to configure one or more custom output-cache providers. Output-cache providers can use any storage mechanism to persist HTML content. This makes it possible to create custom output-cache providers for diverse persistence mechanisms, which can include local or remote disks, cloud storage, and distributed cache engines.
How do you implement custom output caching?
Create a custom output-cache provider as a class that derives from the new System.Web.Caching.OutputCacheProvider type. You can then configure the provider in the Web.config file by using the new providers subsection of the outputCache element, as shown below:
<caching>
<outputCache defaultProvider="AspNetInternalProvider">
<providers>
<add name="DiskCache"
type="Test.OutputCacheEx.DiskOutputCacheProvider, DiskCacheProvider"/>
</providers>
</outputCache>
</caching>
Then specify the newly created and configured custom cache provider as below:
<%@ OutputCache Duration="60" VaryByParam="None" providerName="DiskCache" %>
What is permanent redirecting and how do you implement it?
ASP.Net 4.0 introduced a new URL redirection method RedirectPermanent() which avoids round trips.
You can implement this as shown below:
RedirectPermanent("/newpath/newpage.aspx");
How do you implement ViewState for a control?
In ASP.NET 4, Web server controls include a ViewStateMode property that lets you disable view state by default and then enable it only for the controls that require it in the page.
The ViewStateMode property takes an enumeration that has three values: Enabled, Disabled, and Inherit. Enabled enables view state for that control and for any child controls that are set to Inherit or that have nothing set. Disabled disables view state, and Inherit specifies that the control uses the ViewStateMode setting from the parent control.
<asp:PlaceHolder ID="PlaceHolder1" runat="server" ViewStateMode="Disabled">
Disabled: <asp:Label ID="label1" runat="server" Text="[DeclaredValue]" /><br />
<asp:PlaceHolder ID="PlaceHolder2" runat="server" ViewStateMode="Enabled">
Enabled: <asp:Label ID="label2" runat="server" Text="[DeclaredValue]" />
</asp:PlaceHolder>
</asp:PlaceHolder>
How will the IDs for controls be managed in ASP.Net 4.0?
In ASP.Net 4.0 we can specify how to generate control ids using 'ClientIDMode' attribute instead of generating dynamically like container_controlidXXX.
What are the different ClientIDModes we can set and how will they work?
The new ClientIDMode property lets you specify more precisely how the client ID is generated for controls. You can set the ClientIDMode property for any control, including for the page. Possible settings are the following:
AutoID
This is equivalent to the algorithm for generating ClientID property values that was used in earlier versions of ASP.NET.
Static
This specifies that the ClientID value will be the same as the ID without concatenating the IDs of parent naming containers. This can be useful in Web user controls. Because a Web user control can be located on different pages and in different container controls, it can be difficult to write client script for controls that use the AutoID algorithm because you cannot predict what the ID values will be.
Predictable
This option is primarily for use in data controls that use repeating templates. It concatenates the ID properties of the control's naming containers, but generated ClientID values do not contain strings like "ctlxxx". This setting works in conjunction with the ClientIDRowSuffix property of the control. You set the ClientIDRowSuffix property to the name of a data field, and the value of that field is used as the suffix for the generated ClientID value. Typically you would use the primary key of a data record as the ClientIDRowSuffix value.
Inherit
This setting is the default behavior for controls; it specifies that a control's ID generation is the same as its parent.
What is QueryExtender Control?
QueryExtender Control is an add-on to the DataSource Controls: EntityDataSource and LinqDataSource. QueryExtender is used to filter the data returned by these controls. As the QueryExtender control relies on LINQ, the filter is applied on the database server before the data is sent to the page, which results in very efficient operations.
E.g.:
<asp:LinqDataSource ID="dataSource" runat="server"> TableName="Products">
</asp:LinqDataSource>
<asp:QueryExtender TargetControlID="dataSource" runat="server">
<asp:SearchExpression DataFields="ProductName, Supplier.CompanyName"
SearchType="StartsWith">
<asp:ControlParameter ControlID="TextBoxSearch" />
</asp:SearchExpression>
</asp:QueryExtender>
Q. What is machine.config file and how do you use it in ASP.Net 4.0?
Ans. Machine.Config file is found in the "CONFIG" subfolder of your .NET Framework install directory (c:\WINNT\Microsoft.NET\Framework\{Version Number}\CONFIG on Windows 2000 installations). It contains configuration settings for machine-wide assembly binding, built-in remoting channels, and ASP.NET.
In .the NET Framework 4.0, the major configuration elements(that use to be in web.config) have been moved to the machine.config file, and the applications now inherit these settings. This allows the Web.config file in ASP.NET 4 applications either to be empty or to contain just the following lines.
Q. What is RedirectPermanent in ASP.Net 4.0?
Ans. In earlier Versions of .Net, Response.Redirect was used, which issues an HTTP 302 Found or temporary redirect response to the browser (meaning that asked resource is temporarily moved to other location) which inturn results in an extra HTTP round trip. ASP.NET 4.0 however, adds a new RedirectPermanent that Performs a permanent redirection from the requested URL to the specified URL. and returns 301 Moved Permanently responses.
e.g. RedirectPermanent("/newpath/foroldcontent.aspx");
Q. How will you specify what version of the framework your application is targeting?
Ans. In Asp.Net 4 a new element "targetFramework" of compilation tag (in Web.config file) lets you specify the framework version in the webconfig file as
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation targetFramework="4.0" />
</system.web>
</configuration>
It only lets you target the .NET Framework 4.0 and later verisons.
Q. What is the use of MetaKeywords and MetaDescription properties.
Ans. MetaKeywords and MetaDescription are the new properties added to the Page class of ASP.NET 4.0 Web Forms. The two properties are used to set the keywords and description meta tags in your page.
For e.g.
<meta name="keywords" content="These, are, my, keywords" />
<meta name="description" content="This is the description of my page" />
You can set these properties at run time, which lets you get the content from a database or other source, and which lets you set the tags dynamically to describe what a particular page is for.
You can also set the Keywords and Description properties in the @ Page directive at the top of the Web Forms page markup like,
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" Keywords="ASP,4.0,are keywords" Description="blah blah" %>
Q. What is Microsoft Ajax Library.
Ans. Microsoft Ajax Library is a client-only JavaScript library that is compatible with all modern browsers, including Internet Explorer, Google Chrome, Apple Safari, and Mozilla Firefox.Because the Microsoft Ajax Library is a client-only JavaScript library, you can use the library with both ASP.NET Web Forms and ASP.NET MVC applications. You can also create Ajax pages that consist only of HTML.
Q. What are the Changes in CheckBoxList and RadioButtonList Control ?
Ans. In ASP.NET 4, the CheckBoxList and RadioButtonList controls support two new values for the RepeatLayout property, OrderedList(The content is rendered as li elements within an ol element) and UnorderedList(The content is rendered as li elements within a ul element.)
For more info see : Specify Layout in CheckBoxList and RadioButtonList Control - ASP.Net 4
Q. Whats Application Warm-Up Module?
Ans. We can set-up a Warm-Up module for warming up your applications before they serve their first request.Instead of writing custom code, you specify the URLs of resources to execute before the Web application accepts requests from the network. This warm-up occurs during startup of the IIS service (if you configured the IIS application pool as AlwaysRunning) and when an IIS worker process recycles. During recycle, the old IIS worker process continues to execute requests until the newly spawned worker process is fully warmed up, so that applications experience no interruptions or other issues due to unprimed caches.
Q. How would you Deploy your old applications with .Net Framework 4.0? Are the Old applications compatible?
Ans. .NET Framework 4 is highly compatible with applications that are built with earlier .NET Framework versions. Though Some Changes have been made to improve security, standards compliance, correctness, reliability, and performance.
To run older applications with .NET Framework 4, you will have to re-compile your applications with the target .NET Framework version specified in the properties for your project in Visual Studio Or you can specify the supported runtime with the Element in an application configuration file. .Net Framework 4 does not automatically use its version of the common language runtime to run applications that are built with earlier versions of the .NET Framework.
Q. Whts is Parallel Computing?
Ans. To take advantage of multiple cores (that is, CPUs or processors) you can parallelize your code so that it will be distributed across multiple processors. In the past, parallelization required low-level manipulation of threads and locks, but Visual Studio 2010 and the .NET Framework 4 enhances the support for parallel programming by providing a new runtime, new class library types, and new diagnostic tools. These features simplify parallel development so that you can write efficient, fine-grained, and scalable parallel code in a natural idiom without having to work directly with threads or the thread pool.
The new System.Threading.Tasks namespace and other related types support this new model.
Q. What is BigInteger and When would you use that?
Ans. BigInteger, which is a part of System.Numerics Namespace is a great enhancement over Byte and Int32 datatypes. It is a nonprimitive integral type that supports arbitrarily large signed integers. Unlike Byte and Int32 types, BigInteger does not include a Minvalue and MaxValue property, so can be used to store large integer values.
Q. What other than BigInteger has been introduced in System.Numerics Namespace?
Ans. Complex types,which represents a complex number has been Introduced. a complex number is a number in the form a + bi, where a is the real part, and b is the imaginary part.
Q. How do you assign a Value to a Complex Number.
Ans. You can assign a value to a complex number in few different ways.
1. By passing two Double values to its constructor. The first value represents the real part of the complex number, and the second value represents its imaginary part.
2. By assigning a Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, or Double value to a Complex object. The value becomes the real part of the complex number, and its imaginary part equals 0.
E.g Complex c1 = new Complex(12, 6);
Console.WriteLine(c1);
OutPut - (12, 6)
Q. How has exception hand changed in .Net Framework 4.0
Ans. A New Namespace System.Runtime.ExceptionServices has been introduced which provides classes for advanced exception handling. It has introduced the following classes
1. HandleProcessCorruptedStateExceptionsAttribute Class - Enables managed code to handle exceptions that indicate a corrupted process state.So,If you want to compile an application in the .NET Framework 4 and handle corrupted state exceptions, you can apply this attribute to the method that handles the corrupted state exception.
2.FirstChanceExceptionEventArgs Class -Provides data for the notification event that is raised when a managed exception first occurs, before the common language runtime begins searching for event handlers.
common language runtime and the base class libraries?
Ans. Brief about the Improvements -
Diagnostics and Performance - Starting with the .NET Framework 4, you can get processor usage and memory usage estimates per application domain.
Garbage Collection - This feature replaces concurrent garbage collection in previous versions and provides better performance.
Code Contracts - Code contracts let you specify contractual information that is not represented by a method's or type's signature alone. The new System.Diagnostics.Contracts namespace contains classes that provide a language-neutral way to express coding assumptions in the form of preconditions, postconditions, and object invariants.
Design-Time-Only Interop Assemblies - You no longer have to ship primary interop assemblies (PIAs) to deploy applications that interoperate with COM objects. In the .NET Framework 4, compilers can embed type information from interop assemblies, selecting only the types that an application (for example, an add-in) actually uses.
Dynamic Language Runtime - The dynamic language runtime (DLR) is a new runtime environment that adds a set of services for dynamic languages to the CLR. The DLR makes it easier to develop dynamic languages to run on the .NET Framework and to add dynamic features to statically typed languages. To support the DLR, the new System.Dynamic namespace is added to the .NET Framework.
Covariance and Contravariance - Several generic interfaces and delegates now support covariance and contravariance.
BigInteger and Complex Numbers - The new System.Numerics.BigInteger structure is an integer data type that can store fairly large number as it has no upper and lower bound values.Complex types represents a complex number of form a + bi. IT supports arithmetic and trigonometric operations with complex numbers.
Tuples - The .NET Framework 4 provides the System..::.Tuple class for creating tuple objects that contain structured data.
File System Enumeration Improvements - You can now enumerate directories and files by using methods that return an enumerable collection of strings of their names.ou can also use methods that return an enumerable collection of DirectoryInfo, FileInfo, or FileSystemInfo objects.
Memory-Mapped Files - A memory-mapped file contains the contents of a file in virtual memory and is an application’s logical address space. So You can use memory-mapped files to edit very large files and to create shared memory for interprocess communication.
64-Bit Operating Systems and Processes - You can identify 64-bit operating systems and processes with the Environment.Is64BitOperatingSystem and Environment.Is64BitProcess properties
Q. What are the major improvements provided by the common language runtime and the base class libraries?
Ans. Brief about the Improvements -
Diagnostics and Performance - Starting with the .NET Framework 4, you can get processor usage and memory usage estimates per application domain.
Garbage Collection - This feature replaces concurrent garbage collection in previous versions and provides better performance.
Code Contracts - Code contracts let you specify contractual information that is not represented by a method's or type's signature alone. The new System.Diagnostics.Contracts namespace contains classes that provide a language-neutral way to express coding assumptions in the form of preconditions, postconditions, and object invariants.
Design-Time-Only Interop Assemblies - You no longer have to ship primary interop assemblies (PIAs) to deploy applications that interoperate with COM objects. In the .NET Framework 4, compilers can embed type information from interop assemblies, selecting only the types that an application (for example, an add-in) actually uses.
Dynamic Language Runtime - The dynamic language runtime (DLR) is a new runtime environment that adds a set of services for dynamic languages to the CLR. The DLR makes it easier to develop dynamic languages to run on the .NET Framework and to add dynamic features to statically typed languages. To support the DLR, the new System.Dynamic namespace is added to the .NET Framework.
Covariance and Contravariance - Several generic interfaces and delegates now support covariance and contravariance.
BigInteger and Complex Numbers - The new System.Numerics.BigInteger structure is an integer data type that can store fairly large number as it has no upper and lower bound values.Complex types represents a complex number of form a + bi. IT supports arithmetic and trigonometric operations with complex numbers.
Tuples - The .NET Framework 4 provides the System..::.Tuple class for creating tuple objects that contain structured data.
File System Enumeration Improvements - You can now enumerate directories and files by using methods that return an enumerable collection of strings of their names.ou can also use methods that return an enumerable collection of DirectoryInfo, FileInfo, or FileSystemInfo objects.
Memory-Mapped Files - A memory-mapped file contains the contents of a file in virtual memory and is an application’s logical address space. So You can use memory-mapped files to edit very large files and to create shared memory for interprocess communication.
64-Bit Operating Systems and Processes - You can identify 64-bit operating systems and processes with the Environment.Is64BitOperatingSystem and Environment.Is64BitProcess properties
Q. What is Routing in Asp.Net 4.0 ?
Ans. Routing is a feature in ASP.NET 4.0 that enables you to use URLs to map specific resources. These URLs can then become more descriptive and user friendly like http://server/webapp/Customers/View/ID.
In ASP.NET 4.0 all the necessary components to use ASP.NET Routing are inbuilt. These include theIRouteHandler implementation (PageRouteHandler class) that serves up the right IHttpHandler to service the request and a couple of expression builders to help capture parameters from routed requests and also generate route URLs.
Q. Whats Application Warm-Up Module?
Ans. We can set-up a Warm-Up module for warming up your applications before they serve their first request.Instead of writing custom code, you specify the URLs of resources to execute before the Web application accepts requests from the network. This warm-up occurs during startup of the IIS service (if you configured the IIS application pool as AlwaysRunning) and when an IIS worker process recycles. During recycle, the old IIS worker process continues to execute requests until the newly spawned worker process is fully warmed up, so that applications experience no interruptions or other issues due to unprimed caches.
Q. When would you use the ViewStateMode property of a control.
Ans. ViewStateMode is newly introduced in .net 4.0 and can accept Enabled, Disabled and Inherit values. It is mainly used when you have to disable the viewstate of a control. By default it is set to Inherit. Also, If the EnableViewState property is set to be disabled, setting any values for ViewStateMode property will make no difference.
Q What are the SEO Enhancements in .net 4.0
Ans. ASP.NET 4.0 has make it easier to set the Keywords and Description meta tags on a page. The page class in ASP.NET 4.0 now has two new properties, namely, Keywords and Description. These can be set either in markup code or from the code behind so that you can generate the meta tags dynamically.
Q. How do you Monitor the Performance of your asp.net web application ?
Ans. ASP.NET 4.0 provides support for monitoring the performance of individual applications inside a single worker process. This feature provides a more granular view of the resources being consumed by your application. You use the following in your webconfig.
0 comments