aspx page not loading!!!! Method called too soon

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2006
Posts: 2
Reputation: dba123 is an unknown quantity at this point 
Solved Threads: 0
dba123 dba123 is offline Offline
Newbie Poster

aspx page not loading!!!! Method called too soon

 
0
  #1
Aug 7th, 2006
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:


  1. <%@ Page Language="C#" AutoEventWireup="true"
  2. CodeFile="TestURLRewriter.aspx.cs" Inherits="TestURLRewriter" %>
  3.  
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  5. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6.  
  7. <html xmlns="http://www.w3.org/1999/xhtml" >
  8. <head id="Head1" runat="server">
  9. <title>URL Rewriter Test Page</title>
  10. </head>
  11. <body>
  12. <asp:HyperLink ID="link1" NavigateUrl="/recipes/4/detail.aspx"
  13. runat="server">/recipes/4/detail.aspx</asp:HyperLink>
  14.  
  15. </body>
  16. </html>
  17.  
  18.  
  19. My global.asax:
  20.  
  21.  
  22. void Application_BeginRequest(object sender, EventArgs e)
  23. {
  24. MyNamespace.Web.URLRewriter.Process();
  25. }
  26. ...rest of global.asax...
  27.  
  28.  
  29.  
  30. My .cs page:
  31.  
  32.  
  33. namespace MyNamespace.Web
  34. {
  35. public class URLRewriter : IConfigurationSectionHandler
  36. {
  37. protected XmlNode _oRules;
  38.  
  39. protected URLRewriter(){}
  40. private string recipeID;
  41.  
  42. public static void Process()
  43. {
  44. URLRewriter oRewriter =
  45. (URLRewriter)ConfigurationSettings.GetConfig("system.web/urlrewrites");
  46.  
  47. string rewrittenURL =
  48. oRewriter.GetRewrittenURL(HttpContext.Current.Request.Path);
  49.  
  50. if (rewrittenURL.Length > 0)
  51. {
  52. //Rewrite the path using the rewritten URL
  53. HttpContext.Current.RewritePath(rewrittenURL);
  54. }
  55. }
  56.  
  57. ... rest of .cs page
Last edited by dba123; Aug 7th, 2006 at 1:26 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC