Friday, March 14, 2008

What are the different types of caching?

Caching is a technique widely used in computing to increase performance by keeping frequently accessed or expensive data in memory. In context of web application, caching is used to retain the pages or data across HTTP requests and reuse them without the expense of recreating them.ASP.NET has 3 kinds of caching strategiesOutput CachingFragment CachingData

CachingOutput Caching: Caches the dynamic output generated by a request. Some times it is useful to cache the output of a website even for a minute, which will result in a better performance. For caching the whole page the page should have OutputCache directive.<%@ OutputCache Duration="60" VaryByParam="state" %>

Fragment Caching: Caches the portion of the page generated by the request. Some times it is not practical to cache the entire page, in such cases we can cache a portion of page<%@ OutputCache Duration="120" VaryByParam="CategoryID;SelectedID"%>

Data Caching: Caches the objects programmatically. For data caching asp.net provides a cache object for eg: cache["States"] = dsStates;

What are user controls and custom controls?

Custom controls:
A control authored by a user or a third-party software vendor that does not belong to the .NET Framework class library. This is a generic term that includes user controls.

A custom server control is used in Web Forms (ASP.NET pages). A custom client control is used in Windows Forms applications.

User Controls:
In ASP.NET: A user-authored server control that enables an ASP.NET page to be re-used as a server control. An ASP.NET user control is authored declaratively and persisted as a text file with an .ascx extension. The ASP.NET page framework compiles a user control on the fly to a class that derives from the System.Web.UI.UserControl class.

What is view state and use of it?

The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page. ASP.NET can detect when a form is requested for the first time versus when the form is posted (sent to the server), which allows you to program accordingly.

What method do you use to explicitly kill a users session in ASP.NET?

The Session.Abandon method destroys all the objects stored in a Session object and releases their resources. If you do not call the Abandon method explicitly, the server destroys these objects when the session times out.

What is smart navigation in ASP.NET Pages?

When a page is requested by an Internet Explorer 5 browser, or later, smart navigation enhances the user's experience of the page by performing the following:
  • Eliminating the flash caused by navigation.
  • Persisting the scroll position when moving from page to page.
  • Persisting element focus between navigations.
  • Retaining only the last page state in the browser's history.
  • Smart navigation is best used with ASP.NET pages that require frequent postbacks but with visual content that does not change dramatically on return. Consider this carefully when deciding whether to set this property to true.
Set the SmartNavigation attribute to true in the @ Page directive in the .aspx file. When the page is requested, the dynamically generated class sets this property.

Response.Redirect vs Server.Transfer?

Server.Transfer or Response.Redirect both are the method of choice for transferring the user from one place in the application to another

Server.Transfer is similar in that it sends the user to another page with a statement such as Server.Transfer("WebForm2.aspx"). However, the statement has a number of distinct advantages and disadvantages.

Firstly, transferring to another page using Server.Transfer conserves server resources. Instead of telling the browser to redirect, it simply changes the "focus" on the Web server and transfers the request. This means you don't get quite as many HTTP requests coming through, which therefore eases the pressure on your Web server and makes your applications run faster.
But watch out: because the "transfer" process can work on only those sites running on the server, you can't use Server.Transfer to send the user to an external site. Only Response.Redirect can do that.

The other side debates that Server.Transfer is not user friendly because the page requested may not be the page that shows in the URL. Response.Redirect is more user-friendly, as the site visitor can bookmark the page that they are redirected to.

Secondly, Server.Transfer maintains the original URL in the browser. This can really help streamline data entry techniques, although it may make for confusion when debugging.

That's not all: The Server.Transfer method also has a second parameter"preserveForm". If you set this to True, using a statement such as Server.Transfer("WebForm2.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.

For example, if your WebForm1.aspx has a TextBox control called TextBox1 and you transferred to WebForm2.aspx with the preserveForm parameter set to True, you'd be able to retrieve the value of the original page TextBox control by referencing Request.Form("TextBox1").

Explain the concept of Web Application.?

An introduction to web applications
A web application consists of a set of web pages that are generated in response to user requests. The Internet has many different types of web applications, such as search engines, online stores, auctions, news sites, discussion groups, games, and so on.
Properties of web applications
  • Web applications are a type of client/server application. In that type of application, a user at a client computer accesses an application at a server computer. In a web application, the client and server computers are connected via the Internet or via an intranet (a local area network).
  • In a web application, the user works with a web browser at the client computer. The web browser provides the user interface for the application. The most popular web browsers are Microsofts Internet Explorer, .Mozilla Firefox
  • The application runs on the server computer under the control of web server software. For ASP.NET web applications, the server must run Microsofts web server, called Internet Information Services, or IIS.
  • For most web applications, the server computer also runs a database management system, or DBMS, such as Microsofts SQL Server. The DBMS provides access to information stored in a database. To improve performance on larger applications, the DBMS can be run on a separate server computer.
  • The user interface for a web application is implemented as a series of web pages that are displayed in the web browser. Each web page is defined by a web form using HTML, or Hypertext Markup Language, which is a standardized set of markup tags.
  • The web browser and web server exchange information using HTTP (Hypertext Transfer Protocol).

What is ASP.NET?

ASP.NET is a technology for creating dynamic Web applications. It is part of the .NET Framework; you can write ASP.NET applications in most .NET compatible languages, including Visual Basic, C#, J# and JScript. ASP.NET pages (Web Forms) are compiled, providing better performance than with scripting languages.

Web Forms allow you to build powerful forms-based Web pages. When building these pages, you can use ASP.NET server controls to create common UI elements, and program them for common tasks. These controls allow you to rapidly build a Web Form out of reusable built-in or custom components, simplifying the code of a page.

ASP.NET provides a programming model, and infrastructure, to make creating scalable, secure and stable applications faster, and easier than with previous Web technologies