Tuesday, 2 August 2011

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.

How can we check if all validation and controls are valid or proper?How can we force to run all validation control to run?

By using Page.IsValid() property we can check if all validation and controls are valid or proper by using Page.Validate we can force to run all validation control to run

What is serialization in .NET? What are the ways to control serialization?

Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process of creating an object from a stream of bytes. Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database).


Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created.


1. Binary serialization preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application. For example, you can share an object between different applications by serializing it to the clipboard. You can serialize an object to a stream, disk, memory, over the network, and so forth. Remoting uses serialization to pass objects "by value" from one computer or application domain to another. 

2. XML serialization serializes only public properties and fields and does not preserve type fidelity. This is useful when you want to provide or consume data without restricting the application that uses the data. Because XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is an open standard, which makes it an attractive choice.

What are object pooling and connection pooling and difference? Where do we set the Min and Max Pool size for connection pooling?

Object pooling is a COM+ service that enables you to reduce the overhead of creating each object from scratch. When an object is activated, it is pulled from the pool. When the object is deactivated, it is placed back into the pool to await the next request. You can configure object pooling by applying the ObjectPoolingAttribute attribute to a class that derives from the System.EnterpriseServices.ServicedComponent class. 

Object pooling lets you control the number of connections you use, as opposed to connection pooling, where you control the maximum number reached. 

Following are important differences between object pooling and connection pooling:


1. Creation. When using connection pooling, creation is on the same thread, so if there is nothing in the pool, a connection is created on your behalf. With object pooling, the pool might decide to create a new object. However, if you have already reached your maximum, it instead gives you the next available object. This is crucial behavior when it takes a long time to create an object, but you do not use it for very long. 

2. Enforcement of minimums and maximums. This is not done in connection pooling. The maximum value in object pooling is very important when trying to scale your application. You might need to multiplex thousands of requests to just a few objects. (TPC/C benchmarks rely on this.)

COM+ object pooling is identical to what is used in .NET Framework managed SQL Client connection pooling. For example, creation is on a different thread and minimums and maximums are enforced.

What is Code Access Security (CAS)? How does CAS work?

CAS is the part of the .NET security model that determines whether or not a piece of code is allowed to run, and what resources it can use when it is running. For example, it is CAS that will prevent a .NET web applet from formatting your hard disk.


The CAS security policy revolves around two key concepts - code groups and permissions. Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a named permission set. For example, using the default security policy, a control downloaded from a web site belongs to the 'Zone - Internet' code group, which adheres to the permissions defined by the 'Internet' named permission set. (Naturally the 'Internet' named permission set represents a very restrictive range of permissions.)

ADO and ADO.NET

ADO : Needs contionous connection to read records.
ADO.NET : It reads entire results and keep it the form of 
table. So it never re-connect with DB.
 
 
ADO.NET is stateless mechanism. I can treat the ADO.Net as a
separate in-memory database where in I can use relationships
between the tables and select insert and updates to the
database. I can update the actual database as a batch.
 
ado.net is xml based and ado is com based 
here easy to implement he disconnected model and difficult 
to 


ADO is a Object Based,where as ADO.Net is a Object 
Oriented.

ADO supports record-set,whereas ADO.Net supports data-set

Page.IsCallBack and Page.IsPostBack

Page.IsCallBack
It is getting a value indicating whether the page request is the result of a call back. Its a special postback, so a round-trip always occurs; however, unlike the classic postback, the script callback doesn't redraw the whole page. ViewState is not updated during a callback, it is for postback.
Page.IsPostBack
Checks whether the Page is accessing the server for the first time or not. Unlike the IsCallBack, the ViewState is updated

life cycle of an ASP .NET page

Life cycle stages:-

  1. Page request
  2. Start
  3. Page initialization
  4. Load
  5. Validation
  6. Postback event handling
  7. Rendering
  8. Onload
Life Cycle Events:-

  • PreInit
  • Init
  • InitComplete
  • PreLoad
  • Load
  • Control events
  • LoadComplete
  • PreRender
  • SaveStateComplete
  • Render
  • Unload


What is smart navigation?

The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.

How to display a Wait page while a query is running?


Where can I get the details on Migration of existing projects using various technologies to ASP.NET?

Microsoft has designed Migration Assistants to help us convert existing pages and applications to ASP.NET. It does not make the conversion process completely automatic, but it will speed up project by automating some of the steps required for migration.
Below are the Code Migration Assistants
  • ASP to ASP.NET Migration Assistant
  • PHP to ASP.NET Migration Assistant
  • JSP to ASP.NET Migration Assistant
Refer Migrating to ASP.Net

What is a ViewState?

In classic ASP, when a form is submitted the form values are cleared. In some cases the form is submitted with huge information. In such cases if the server comes back with error, one has to re-enter correct information in the form. But submitting clears up all form values. This happens as the site does not maintain any state (ViewState).
In ASP .NET, when the form is submitted the form reappears in the browser with all form values. This is because ASP .NET maintains your ViewState. ViewState is a state management technique built in ASP.NET. Its purpose is to keep the state of controls during subsequent postbacks by the same user. The ViewState indicates the status of the page when submitted to the server. The status is defined through a hidden field placed on each page with a <form runat="server"> control.

<input type="hidden" name="__VIEWSTATE" value="dDwyNTA3OTU0NDM7Oz7t5TntzkOUeB0QVV6FT2hvQwtpPw==" /> 


If you want to NOT maintain the ViewState, include the directive <%@ Page EnableViewState="false"%> at the top of an .aspx page If you do not want to maintain Viewstate for any control add the attribute EnableViewState="false" to any control.

How to comment out ASP.NET Tags?



<%--<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 48px" runat="server">Label</asp:Label>--%>

Is it possible to pass a querystring from an .asp page to aspx page?

Yes you can pass querystring from .asp to ASP.NET page .asp

<%response.redirect "webform1.aspx?id=11"%>


.aspx
VB.NET

Response.Write (Request("id").ToString ())


C#

Response.Write (Request["id"].ToString ());

How to find out what version of ASP.NET I am using on my machine?

VB.NET

Response.Write(System.Environment.Version.ToString() )


C#

Response.Write(System.Environment.Version.ToString() );

Why does my ASP.NET file have multiple "form'tag with runat=server?

This means that ASP.Net is not properly registered with IIS.
.Net framework provides an Administration utility that manages the installation and uninstallation of multiple versions of ASP.NET on a single machine. You can find the file in C:\WINNT\Microsoft.NET\Framework\v**\aspnet_regiis.exe

use the command: aspnet_regiis.exe -u ---> to uninstall current asp.net version.
use the command: aspnet_regiis.exe -i ---> to install current asp.net version.


For Windows Server 2003, you must use aspnet_regiis -i -enable
This is because of the "Web Service Extensions" feature in IIS 6

What is ASP.NET?

ASP.NET is a programming framework built on the common language run-time that can be used on a server to build powerful Web applications.