944,214 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 3252
  • C# RSS
Aug 7th, 2006
0

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

Expand Post »
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:


C# Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dba123 is offline Offline
2 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Problem with the keyboard hooks
Next Thread in C# Forum Timeline: DataGridView - how to get invalid data in comboboxcell





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC