Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 6th, 2006, 11:18 PM
Authorized User
 
Join Date: Feb 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default aspx page not loading!!!! Method called too soon

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" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>URL Rewriter Test Page</title>
</head>
<body>
     <asp:HyperLink ID="link1" NavigateUrl="/recipes/4/detail.aspx"
runat="server">/recipes/4/detail.aspx</asp:HyperLink>

     </body>
</html>


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("syst em.web/urlrewrites");

            string rewrittenURL =
oRewriter.GetRewrittenURL(HttpContext.Current.Requ est.Path);

            if (rewrittenURL.Length > 0)
            {
                //Rewrite the path using the rewritten URL
                HttpContext.Current.RewritePath(rewrittenURL);
            }
        }








Similar Threads
Thread Thread Starter Forum Replies Last Post
Master Page Method: Code-Behind for Content Page kwilliams ASP.NET 2.0 Professional 3 June 2nd, 2008 12:57 PM
wrapper class getWriter() method never called milspecs Apache Tomcat 0 January 26th, 2005 05:27 PM
Nested frames crash page when called on XP Umen Javascript 4 September 23rd, 2004 10:55 AM
How to pass variables from Aspx page to Asp Page jayaraj Classic ASP Basics 2 May 23rd, 2004 06:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.