Forum Moderators: open
In your Global.asax file, modify the Application_BeginRequest event as the following:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
HttpContext incoming = HttpContext.Current;
string oldpath = incoming.Request.Path.ToLower();
string pageid; // page id requested
// Regular expressions to grab the page id from the pageX.aspx
Regex regex = new Regex(@"page(\d+).aspx", RegexOptions.IgnoreCase
¦ RegexOptions.IgnorePatternWhitespace);
MatchCollection matches = regex.Matches(oldpath); If (matches.Count > 0)
{
// Extract the page id and send it to Process.aspx
pageid = matches[0].Groups[1].ToString();
incoming.RewritePath("Process.aspx?pageid=" + pageid);
}
else
{
// Display path if it doesn’t contain pageX.aspx
incoming.RewritePath(oldpath
}
}
Your code
Next create a file Process.aspx which would display your web site content based on the pageid parameter (pageid=1…n) just like normal.
Eg...
<%
string pageid = Request.QueryString["pageid"];
// Create the page content based on this pageid taken here
%>