Wednesday, September 10, 2008

Difference between Server.Transfer and Response.Redirect

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 perform as 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.

Some .net tips....

Difference between Response.Write() and Response.Output.Write()...
Response.Output.Write() allows you to write formatted output.

Methods are fired during the page load...
Init() - when the page is instantiated
Load() - when the page is loaded into server memory
PreRender() - the brief moment before the page is displayed to the user as HTML
Unload() - when page finishes loading.

Difference between Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs "...
CodeBehind is relevant to Visual Studio.NET only.

Data types supported by RangeValidator

The following data types are supported for RangeValidator control
Integer, String, and Date.

Converting XMLContent to String

Following code will help you to simply read a XML file and get the content in string object

public string ConvertXMLToString(string xmlFilePath)
{
string xmlOutput = "";
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(xmlFilePath);
if (xmlDocument != null)
{
xmlOutput = xmlDocument.OuterXml.ToString();
}
xmlDocument = null;
return xmlOutput;
}