Tuesday, March 29, 2011

adding META data when using master page?

Step 1: In your master page define this:

....

< head>
< asp:ContentPlaceHolder ID="ContentSEO" runat="server" />
< meta http-equiv="content-type" content="text/html; charset=utf-8" />
< meta http-equiv="content-language" content="en" />

...

....


Step 2: Now within the child pages, add this:

< %@ Page Language="VB" MasterPageFile="~/masters/Default.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="home_Default" Title="Untitled Page" %>
< asp:Content ID="ctlSEO" ContentPlaceHolderID="ContentSEO" runat="server">
< title>Your title< /title>
< meta name="Keywords" content="your,keywords" />
< meta name="Description" content="Your Keywords" />
< /asp:Content>
......

Monday, March 21, 2011

How to read a remote web page in Asp.Net

Two classes in the System.Net namespace make it very easy to obtain the html of a remote web page. These are the HttpWebRequest and HttpWebResponse. Here's a quick demo.

The static method below makes an http request for a web page, and the resulting string of html within the http response is captured and returned to the caller.


//using System.Net;
//using System.IO;
static string GetHtmlPage(string strURL)
{

String strResult;
WebResponse objResponse;
WebRequest objRequest = HttpWebRequest.Create(strURL);
objResponse = objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
strResult = sr.ReadToEnd();
sr.Close();
}
return strResult;
}


And to call the method:
string TheUrl = "http://www.something.com/Default.aspx";
string response = GetHtmlPage(TheUrl);



OR

WebClient webclient = new WebClient();
string source = webclient.DownloadString("http://www.something.com/Default.aspx");

App_Offline.htm in Asp.net

Basically, if you place a file with this name in the root of a web application directory, ASP.NET 2.0 will shut-down the application, unload the application domain from the server, and stop processing any new incoming requests for that application. ASP.NET will also then respond to all requests for dynamic pages in the application by sending back the content of the app_offline.htm file (for example: you might want to have a “site under construction” or “down for maintenance” message).

This provides a convenient way to take down your application while you are making big changes or copying in lots of new page functionality (and you want to avoid the annoying problem of people hitting and activating your site in the middle of a content update). It can also be a useful way to immediately unlock and unload a SQL Express or Access database whose .mdf or .mdb data files are residing in the /app_data directory.

Once you remove the app_offline.htm file, the next request into the application will cause ASP.NET to load the application and app-domain again, and life will continue along as normal.

Sunday, March 20, 2011

ASP.NET Interview Questions

1. Describe the role of inetinfo.exe, aspnet_isapi.dll and aspnet_wp.exe in the page loading process.
-inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.


2. What’s the difference between Response.Write() and Response.Output.Write()?


Resopnse.Output.Write..
1.Formatted output will be displayed.
2.It gives String.Format-style formatted output.
3.It writes the HTTP Output Stream.
4.As per specified options it formats the string and then write to web page.
eg: Response.Write("Welcome to asp.net")

Response.Write..
1.unformatted output will be displayed.
2.It never gives like that.
3.It writes the text stream
4.It just output a string to web page
eg: Response.Output.Write("< h2>Once again running as {0}</h2>",WindowsIdentity.GetCurrent().Name);

3. What methods are fired during the page load?
-Init() - when the pageis instantiated,
-Load() - when the page is loaded into server memory,
-PreRender() - the brief moment before the page is displayed to the user asHTML,
-Unload() - when page finishes loading.

4. Where does the Web page belong in the .NET Framework class hierarchy?
-System.Web.UI.Page
5. Where do you store the information about the user’s locale?
-System.Web.UI.Page.Culture

6. What’s the difference between Codebehind="MyCode.aspx.cs" and src="MyCode.aspx.cs"?
-CodeBehind is relevant to Visual Studio.NET only.

Code All build Assembly is placed inside the bin folder
Src the source cs file/vb fiel is placed in the source
folder and the source file is complied and assembly is
placed inside bin folder during runtime of the aspx page

7. What’s a bubbled event?
-When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.

8. Suppose you want a certain ASP.NET function executed on MouseOver overa certain button. Where do you add an event handler?
-It’s the Attributesproperty, the Add function inside that property. So btnSubmit.Attributes.Add("onMouseOver","someClientCode();");

9. What data type does the RangeValidator control support?
-Integer,String and Date.

10. Explain the differences between Server-side and Client-side code?
-Server side code get executed on the web server in the response of request for any aspx page
where client-side code get executed on the client browser (e.g validation of controls, dynamically hidding and displaying some of controls or there values etc)

11. What type of code (server or client) is found in a Code-Behind class?
-Server side code is found in the code behind file (you can output a string of code that will get printed on web browser like java script , which will get executed on client browser. but only line of code that can get executed on server i.e included in code behind file)

12. Should validation (did the user enter a real date) occur server-side or client-side? Why?
-Client-side. This reduces an additional request to the server to validate the users input.

13. What does the "EnableViewState" property do? Why would I want it on or off?
-EnableViewState property - holds the state of the web control. View state holds the proprty details as a group of a particular web control. And can be sent via HTTPEnable view state must eb enableed for transfering throught he HTTP requests.If the webserver control is using the database request then it is advisable to make the Enable viewState = false to improve the processor performance cause the database will overide the state.

14. What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?
-Server.transfer transfer the page processing from one page to another page without making a round trip back to the client where as response.redirect redirect to another URL and it make a round trip back to the client.

Server.transfer can not transfer page processing from one page to another if the transferred page is in separate application.

15. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?

• A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
• A DataSet is designed to work without any continuing connection to the original data source.
• Data in a DataSet is bulk-loaded, rather than being loaded on demand.
• There's no concept of cursor types in a DataSet.
• DataSets have no current record pointer You can use For Each loops to move through the data.
• You can store many edits in a DataSet, and write them to the original data source in a single operation.
• Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.

16. Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines?
-Application Start - We can place code to initialize variables once during application start. (e.g db connection string)

Session Start - We can place code to initialize variables specific to the session (e.g USER ID and other specific info related to this session)

17. If I’m developing an application that must accommodate multiple security levels though secure login and my ASP.NET web application is spanned across three web-servers (using round-robin load balancing) what would be the best approach to maintain login-in state for the users?
-Maintain the login state security through a database.

18. Can you explain what inheritance is and an example of when you might use it?
-In Inheritance we can use one class property into another
class..
using System;
class sample
{
public void display()
{
Console.WriteLine("C#");
}
}
class sample1:sample
//(Inheriting the property of class sample in class sample1)
{
public void disp()
{
Console.WriteLine("C++");
}
}
class Test
{
public static void Main()
{
sample1 sm=new sample1(); //creating a object of sample1
sm.display(); //accessing function of sample class
sm.disp();
}

19. Whats an assembly?
-Assembly's are building blocks of .Net framework application. It contains single or multiple executable files.

20. Describe the difference between inline and code behind.
-Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.

21. Explain what a diffgram is, and a good use for one?

1.Its an XML format.
2.Current and original versions of Data elements can be identified through Diffgram.
3.Here, loading of contents can be done through dataset.
4.It serialize its contents for transport across a network connection.
5.The column values from both the Original and Current row versions, row error information, and row order will be included.
6.Its a format intended for network data exchange and .NET remoting.

22. Whats MSIL, and why should my developers need an appreciation of it if at all?
-MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL.

23. Which method do you invoke on the DataAdapter control to load your generated dataset with data?
-Fill() method of DataAdapter

SqlDataAdapter da=new SqlDataAdapter();
DataSet ds=new DataSet();
da.Fill(ds);

24. Can you edit data in the Repeater control?
-No, it just reads the information from its data source

25. Which template must you provide, in order to display data in a Repeater control?
-ItemTemplate.To display data in the ItemTemplate declare one or more Web server controls and set their data-binding expressions to evaluate to a field in the Repeater control's (that is the container control's) DataSource.

26. How can you provide an alternating color scheme in a Repeater control?
-Using AlternateItemTemplate and setting the color in Rowstyle or in the HTML control you have used.

27. What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?
-You must set the DataSource property and call the DataBind
method.

28. What base class do all Web Forms inherit from?
-System.Web.UI.Page

29. Name two properties common in every validation control?
-ControlToValidate property and Text property.

30. What tags do you need to add within the asp:datagrid tags to bind columns manually?
-Set AutoGenerateColumns Property to false on the datagrid tag

31. What tag do you use to add a hyperlink column to the DataGrid?
- < asp:HyperLinkColumn>

32. What is the transport protocol you use to call a Web service?
-SOAP(Simple Object Access Protocol). Transport Protocols: It is essential for the acceptance of Web Services that they are based on established Internet infrastructure. This in fact imposes the usage of of the HTTP, SMTP and FTP protocols based on the TCP/IP family of transports. Messaging Protocol: The format of messages exchanged between Web Services clients and Web Services should be vendor neutral and should not carry details about the technology used to implement the service. Also, the message format should allow for extensions and different bindings to specific transport protocols. SOAP and ebXML Transport are specifications which fulfill these requirements. We expect that the W3C XML Protocol Working Group defines a successor standard.

33. True or False: A Web service can only be written in .NET?
-False. A web service is based on SOAP (Simple Object Access Protocol). So any technology which is able to implement SOAP should be able to create a web service. For example we can create web service in .NET and Java.

34. What does WSDL stand for?
-WSDL stands for Web Services Description Language. It is an XML representation of the web service interface.

There are two types of the operations specified in the WSDL file as represented by the attribute of the file.

1. Document oriented operations -- are the ones which contain XML documents as input and output
2. Result oriented operations -- are the ones which contain input parameters as the input message and result as the output message

35. Where on the Internet would you look for Web services?
-(http://www.uddi.org)
-UDDI - Universal description discovery and integration

- UDDI registry will act as a search engine for web services

36. Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?
-DataTextField property

37. Which control would you use if you needed to make sure the values in two different controls matched?
-CompareValidator Control

38. True or False: To test a Web service you must create a windows application or Web application to consume this service?
-False, the webservice comes with a test page and it provides HTTP-GET method to test.

39. How many classes can a single .NET DLL contain?
-A single Dll can contain one or many solutions as u want.
Reason being all the classes that you are creating will be
a part of the Project that u r working on. Once compiled
this project will turn into a single Dll.

40. Explain how server form post-back works (perhaps ask about view state as well).
-Post Back:

The process in which a Web page sends data back to the same page on the server.

View State:

ViewState is the mechanism ASP.NET uses to keep track of server control state values that don't otherwise post back as part of the HTTP form.

ViewState Maintains the UI State of a Page
ViewState is base64-encoded.
It is not encrypted but it can be encrypted by setting EnableViewStatMAC= true & setting the machineKey validation type to 3DES.
If you want to NOT maintain the ViewState include the directive < @ Page EnableViewState= false > at the top of an .aspx page or add the attribute EnableViewState= false to any control.

41. What is the difference between a namespace and assembly name?
-A namespace is a logical naming scheme for types in which a simple type name, such as MyType, is preceded with a dot-separated hierarchical name. Such a naming scheme is completely under control of the developer. For example, types MyCompany.FileAccess.A and MyCompany.FileAccess.B might be logically expected to have functionally related to file access. The .NET Framework uses a hierarchical naming scheme for grouping types into logical categories of related functionality, such as the ASP.NET application framework, or remoting functionality. Design tools can make use of namespaces to make it easier for developers to browse and reference types in their code.
The concept of a namespace is not related to that of an assembly. A single assembly may contain types whose hierarchical names have different namespace roots, and a logical namespace root may span multiple assemblies. In the .NET Framework, a namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.

42. What is GAC?
-GAC stands for Global Assembly Cache. It is used for storing shared assemblies. It stores all versions of a particular assembly so that on updating an assembly the existing applications which use the earlier version do not break.

For storing an assembly into the GAC you need to sign the assembly with a strong name. For this purpose follow these steps:

1. Use sn.exe command line utility to generate a key pair
2. Add the key file name to the assembly as value for AssemblyKeyFileAttribute.
3. Build the assembly.
4. Use gacutil.exe -i command on the command prompt to install it in the cache.

43. What is Reflection?
-It extends the benefits of metadata by allowing developers to inspect and use it at runtime. For example, dynamically determine all the classes contained in a given assembly and invoke their methods.
Reflection provides objects that encapsulate assemblies, modules, and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object. You can then invoke the type's methods or access its fields and properties.
Namespace: System.Reflection

44. What is Delegation?
-A delegate acts like a strongly type function pointer. Delegates can invoke the methods that they reference without making explicit calls to those methods.
Delegate is an entity that is entrusted with the task of representation, assign or passing on information. In code sense, it means a Delegate is entrusted with a Method to report information back to it when a certain task (which the Method expects) is accomplished outside the Method's class.

45. Where does session maintains? How it Maintains?
-session will be maintained in serverside insted of in web server we can use SQL Server to store the session for this we have to change session state mode.session state modes are 4 types
1. InProc ( For Local WebServer)
2.OutProc (To store session in diffrent web server)
3.Sql State (Storing session in sql server)
4.Off (off)

46. What is the purpose of Execute scalar method of Command object ?
-ExecuteScalar method is used to retrieve a single value (EX: aggregate value such as Count etc) from a database

47. How to create a permanent cookie?
-Setting a permanent cookie is similar to Session cookie except give the cookie an expiration date too. It is very common that you don't specify any arbitrary expiration date but instead expire the cookie relative to the current date using the DateAdd() function.
Response.Cookies( Name ) = myCookie;
Response.Cookies( Name ).Expires = DateAdd( m 1 Now());

48. What is caching? What are different ways of caching in ASP.NET?
-Caching is a technique of persisting the data in memory for immediate access to requesting program calls. This is considered as the best way to enhance the performance of the application.

Caching is of 3 types:
Output Caching - Caches the whole page.
Fragment Caching - Caches a part of the page
Data Caching - Caches the data

49. What is meant by 3-tier architecture.?
-We generally split our application into 3-Layers
1)Presentation Layer ( Where we keep all web forms Master Pages and User Controls).
2)Business Layer (Where we keep business logic). e.g Code related to manipulating data Custom Exception classes Custom Control classes Login related code if any etc. etc.
3)Data Access Layer (Where we keep code used to interact with DB). e.g. We can have the methods which are using SQL Helper (Application Block).

50. What is the exact purpose of http handlers?
-ASP.NET maps HTTP requests to HttpHandlers. Each HttpHandler enables processing of individual HTTP URLs or groups of URL extensions within an application. HttpHandlers have the same functionality as ISAPI extensions with a much simpler programming model

Ex
1.Default HttpHandler for all ASP.NET pages ->ASP.NET Page Handler (*.aspx)
2.Default HttpHandler for all ASP.NET service pages->ASP.NET Service Handler (*.asmx)

An HttpHandler can be either synchronous or asynchronous. A synchronous handler does not return until it finishes processing the HTTP request for which it is called. An asynchronous handler usually launches a process that can be lengthy and returns before that process finishes
After writing and compiling the code to implement an HttpHandler you must register the handler using your application's Web.config file.

Monday, March 14, 2011

Conditionally hide CommandField or ButtonField in Gridview.

Suppose FieldName is the Bit field which tells whether the link should be visible true or false 

so design your gridview template like this


</asp:TemplateField>
<asp:TemplateField HeaderText="Auth">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" Text="as" Visible='<%# SetVisible(Eval("FieldName"))%>'
CommandName="Auth" runat="server">MoreInfo</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>


now write your server code like this

public bool SetVisible(object obj_Status)
{
if(obj_Status==DBNull.Value)
return false;
else if (Convert.ToBoolean(obj_Status))
return true;
else
return false;
}
 
 

Sunday, March 13, 2011

Encryption and Decryption in C#

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

///
/// Summary description for EncryptionDecryption
///

public class EncryptionDecryption
{

//Encription
public string base64Encode(string sData)
{
try
{
byte[] encData_byte = new byte[sData.Length];

encData_byte = System.Text.Encoding.UTF8.GetBytes(sData);

string encodedData = Convert.ToBase64String(encData_byte);

return encodedData;

}
catch (Exception ex)
{
throw new Exception("Error in base64Encode" + ex.Message);
}
}


// Decryption
public string base64Decode(string sData)
{

System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();

System.Text.Decoder utf8Decode = encoder.GetDecoder();

byte[] todecode_byte = Convert.FromBase64String(sData);

int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);

char[] decoded_char = new char[charCount];

utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);

string result = new String(decoded_char);

return result;

}

}

Saturday, March 12, 2011

Zip / Unzip folders and files with C#

Using the free library SharpZipLib ,

using System;
using System.Collections;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;

namespace FolderZipper
{
public static class ZipUtil
{
public static void ZipFiles(string inputFolderPath, string outputPathAndFile, string password)
{
ArrayList ar = GenerateFileList(inputFolderPath); // generate file list
int TrimLength = (Directory.GetParent(inputFolderPath)).ToString().Length;
// find number of chars to remove // from orginal file path
TrimLength += 1; //remove '\'
FileStream ostream;
byte[] obuffer;
string outPath = inputFolderPath + @"\" + outputPathAndFile;
ZipOutputStream oZipStream = new ZipOutputStream(File.Create(outPath)); // create zip stream
if (password != null && password != String.Empty)
oZipStream.Password = password;
oZipStream.SetLevel(9); // maximum compression
ZipEntry oZipEntry;
foreach (string Fil in ar) // for each file, generate a zipentry
{
oZipEntry = new ZipEntry(Fil.Remove(0, TrimLength));
oZipStream.PutNextEntry(oZipEntry);

if (!Fil.EndsWith(@"/")) // if a file ends with '/' its a directory
{
ostream = File.OpenRead(Fil);
obuffer = new byte[ostream.Length];
ostream.Read(obuffer, 0, obuffer.Length);
oZipStream.Write(obuffer, 0, obuffer.Length);
}
}
oZipStream.Finish();
oZipStream.Close();
}


private static ArrayList GenerateFileList(string Dir)
{
ArrayList fils = new ArrayList();
bool Empty = true;
foreach (string file in Directory.GetFiles(Dir)) // add each file in directory
{
fils.Add(file);
Empty = false;
}

if (Empty)
{
if (Directory.GetDirectories(Dir).Length == 0)
// if directory is completely empty, add it
{
fils.Add(Dir + @"/");
}
}

foreach (string dirs in Directory.GetDirectories(Dir)) // recursive
{
foreach (object obj in GenerateFileList(dirs))
{
fils.Add(obj);
}
}
return fils; // return file list
}


public static void UnZipFiles(string zipPathAndFile, string outputFolder, string password, bool deleteZipFile)
{
ZipInputStream s = new ZipInputStream(File.OpenRead(zipPathAndFile));
if (password != null && password != String.Empty)
s.Password = password;
ZipEntry theEntry;
string tmpEntry = String.Empty;
while ((theEntry = s.GetNextEntry()) != null)
{
string directoryName = outputFolder;
string fileName = Path.GetFileName(theEntry.Name);
// create directory
if (directoryName != "")
{
Directory.CreateDirectory(directoryName);
}
if (fileName != String.Empty)
{
if (theEntry.Name.IndexOf(".ini") < 0) { string fullPath = directoryName + "\\" + theEntry.Name; fullPath = fullPath.Replace("\\ ", "\\"); string fullDirPath = Path.GetDirectoryName(fullPath); if (!Directory.Exists(fullDirPath)) Directory.CreateDirectory(fullDirPath); FileStream streamWriter = File.Create(fullPath); int size = 2048; byte[] data = new byte[2048]; while (true) { size = s.Read(data, 0, data.Length); if (size > 0)
{
streamWriter.Write(data, 0, size);
}
else
{
break;
}
}
streamWriter.Close();
}
}
}
s.Close();
if (deleteZipFile)
File.Delete(zipPathAndFile);
}
}
}

Thursday, March 10, 2011

Enable or Disable RequiredFieldValidator with Javascript

Sometimes we need to Enable or Disable validation on client side.For that use ValidatorEnable function in the Asp.net javacsript Script Library.

For that set EnableClientScript property of validator to True.

Here i give example for this:

I have a page with a couple of radio buttons.On radio button selection i want to enable/disable validation.

In example if i select Email radio button then Email div will display and only txtEmail textbox validator is enabled.

Java Script for this:

< script language="JavaScript" type="text/javascript">
function autoSelect(control,type)
{
if(type=="Email")
{
document.getElementById('Email').style.display="block";
document.getElementById('PhoneNo').style.display="none";
ValidatorEnable(document.getElementById("RequiredFieldValidator1"), true);
ValidatorEnable(document.getElementById("RequiredFieldValidator2"), false);

}
else
{
document.getElementById('Email').style.display="none";
document.getElementById('PhoneNo').style.display="block";
ValidatorEnable(document.getElementById("RequiredFieldValidator1"), false);
ValidatorEnable(document.getElementById("RequiredFieldValidator2"), true);
}
}


Code for this:


Email :
< input type="radio" id="RadioButton1" runat="server" value="Plan1" name="Plan" onclick="autoSelect(this,'Email')" checked />
PhoneNo :
< input type="radio" id="RadioButton2" runat="server" value="Plan1" name="Plan" onclick="autoSelect(this,'PhoneNo')" />
< div id="Email">
Email
< asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Email Required" ControlToValidate="txtEmail" EnableClientScript="true" ValidationGroup="vgSubmit" />

< div id="PhoneNo" style="display:none">
PhoneNo < asp:TextBox ID="txtPhoneNo" runat="server" />
< asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="PhoneNo Required" ControlToValidate="txtPhoneNo" EnableClientScript="true" ValidationGroup="vgSubmit"/>

< asp:Button ID="btnSubmit" runat="server" Text="Button" ValidationGroup="vgSubmit"/>

Sunday, March 6, 2011

Setting Default URL in Web.Config for website

< system.web>
< urlMappings>
< add url="~/Default.aspx" mappedUrl="~/YourPage.aspx"/>
< /urlMappings>
< /system.web>

Saturday, March 5, 2011

URL rewriting using Global.asax in Asp.Net

There are lots of emerging technologies and Languages that come in existence to develop web sites. Some of them are PHP, JSP, Asp.net etc. Some web sites are static and some are Dynamic web site. Static Web site are Very Search engine Friendly because They have Static Hyperlink in their Content. I.e.: they don’t use any parameter to display there content. But in Dynamic Web Site Content depend on Parameter.
Unluckily, most of these databases driven web sites depends heavily on parameters to display contents since parameter passing is the easiest way to pass information between web pages.
However, most of the search engines cannot or will not list any dynamic URLS. Dynamic URLs are said to contain elements such as ?, &, %, +, =, $, etc. Hence, the pages which the hyperlinks point to will be ignored by the Web spider indexing the site.
But After the research on these dynamic websites and search engine mythology. There comes a new Concept of creating Search engine friendly urls for Dynamic Web site, called url rewriting. In this Concept we create Some virtual url. When they invoked then main url System check the url and take appropriate action.
This Article is using Asp.net (C#.net) technology. Use Global.asax file to implement this code on Application_BeginRequest. This event fire whenever Client browser make request for the site.
Main Goal of this Article is to Replaced Parameterized Url in to static URL.
We are replacing url like
http://www.Somedomain.com?bookid=81, url is not search engine friendly for better indexing.
Change it to
http://www.Somedomain.com?book81.aspx
First of All Some changes are to be made by you.
In your Global.asax file, modify the Application_BeginRequest event as the following,

protected void Application_BeginRequest(Object sender, EventArgs e)
{

HttpContext incomingRequest = HttpContext.Current;
string oldpath = incomingRequest.Request.Path.ToLower();
string bookid; // book id requested

// Regular expressions to grab the book id from the bookX.aspx
Regex regex = new Regex(@"book(\d+).aspx", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
MatchCollection matches = regex.Matches(oldpath);

if (matches.Count > 0)
{
// Extract the book id and send it to ProcessBook.aspx
bookid = matches[0].Groups[1].ToString();
incomingRequest.RewritePath("ProcessBook.aspx?bookid=" + bookid);
}
else
// Display path if it doesn’t containt bookX.aspx pattern where x is an book id.
incomingRequest.RewritePath(oldpath);
}


In the above code, URLs of incoming requests are scanned to determine if the URL includes “bookX.aspx” , where X=1,2,3…n

Next create a file ProcessBook.aspx which would display book content on your web site based on the bookid parameter (bookid=1…n) just like you would do normally.

Ex.

Now You have to test this By Calling the page like http://www. Somedomain.com /book12.aspx

Here even though you are issuing a search engine friendly request, in the background you’re managing your parameters like you would normally do with parameters.This Method is implemented in Global.asax. You can Also create HTTPHandler Module To Track this.

Ajax CalendarExtender displaying at wrong position in Chrome

< script type ="text/javascript" language ="javascript">     function onCalendarShown(sender, args)...