Why isn't my aspx page rendering before the process() method call? What is
happening is when I run my page in debug mode, my aspx page never renders, and it's jumping straight into my process() method when I run in debug mode in VS 2005, using the VS
built-in web engine.
What should happen is I start debug, my aspx page loads, I click on the hyperlink, and that initiates process() to run. It's not happening that way though, why?
See related article here (http://www.codeproject.com/aspnet/urlrewriter.asp) and then my code below :
My aspx page:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="TestURLRewriter.aspx.cs" Inherits="TestURLRewriter" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
http://www.w3.org/1999/xhtml" >
My global.asax:
void Application_BeginRequest(object sender, EventArgs e)
{
MyNamespace.Web.URLRewriter.Process();
}
...rest of global.asax...
My .cs page:
namespace MyNamespace.Web
{
public class URLRewriter : IConfigurationSectionHandler
{
protected XmlNode _oRules;
protected URLRewriter(){}
private string recipeID;
public static void Process()
{
URLRewriter oRewriter =
(URLRewriter)ConfigurationSettings.GetConfig("system.web/urlrewrites");
string rewrittenURL =
oRewriter.GetRewrittenURL(HttpContext.Current.Request.Path);
if (rewrittenURL.Length > 0)
{
//Rewrite the path using the rewritten URL
HttpContext.Current.RewritePath(rewrittenURL);
}
}
Replies
Know the answer? Post it — somebody with the same question will find it here.