Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3671904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:32:38+00:00 2026-05-19T02:32:38+00:00

I’ve recently set up an ASP.net site (not using MVC.net) to use URL Routing

  • 0

I’ve recently set up an ASP.net site (not using MVC.net) to use URL Routing (more on the code below) – when using user controls on the site (i.e I’ve created a “menu” user control to hold menu information) the page_load event for that control will fire twice when URLs have more than one variable passed over.

i.e.

pageName/VAR1 : will only fire the page_load event once.

while

pageName/VAR1/VAR2 : will fire the page_load event twice.

*Multiple extra VARs added on the end will still only fire the page_load event twice*.


Below are the code snippits from the files, the first is the MapPageRoute, located in the Global.asax :

// Register a route for the Example page, with the NodeID and also the Test123 variables allowed.
// This demonstrates how to have several items linked with the page routes.
    routes.MapPageRoute(
        "Multiple Data Example",                    // Route name
        "Example/{NodeID}/{test123}/{variable}",     // Route URL - note the NodeID bit
        "~/Example.aspx",                            // Web page to handle route
        true,                                        // Check for physical access
        new System.Web.Routing.RouteValueDictionary 
        { 
            { "NodeID", "1" },        // Default Node ID
            { "test123", "1" },       // Default addtional variable value
            { "variable", "hello"}    // Default test variable value
        }  
    );

Next is the way I’ve directed to the page in the menu item, this is a list item within a UL tag :

<li class="TopMenu_ListItem"><a href="<%= Page.GetRouteUrl("Multiple Data Example", new System.Web.Routing.RouteValueDictionary { { "NodeID", "4855" }, { "test123", "2" } }) %>">Example 2</a></li>

And finally the control that gets hit multiple times on a page load :

// For use when the page loads.
    protected void Page_Load(object sender, EventArgs e)
    {
        // Handle the routing variables.
        // this handles the route data value for NodeID - if the page was reached using URL Routing.
        if (Page.RouteData.Values["NodeID"] != null)
        {
            nodeID = Page.RouteData.Values["NodeID"] as string;
        };

        // this handles the route data value for Test123 - if the page was reached using URL Routing.
        if (Page.RouteData.Values["Test123"] != null)
        {
            ExampleOutput2.Text = "I am the output of the third variable : " + Page.RouteData.Values["Test123"] as string;
        };

        // this handles the route data value for variable - if the page was reached using URL Routing.
        if (Page.RouteData.Values["variable"] != null)
        {
            ExampleOutput3.Text = "I say " + Page.RouteData.Values["variable"] as string;
        };
    }

Note, that when I’m just hitting the page and it uses the default values for items, the reloads do not happen.


Any help or guidance that anyone can offer would be very much appreciated!

EDIT : The User Control is only added to the page once. I’ve tested the load sequence by putting a breakpoint in the page_load event – it only hits twice when the extra routes are added.

EDIT2 : Thanks again to those who’ve helped out so far – I’m still having trouble finding the cause of the double load – does anyone else have any more suggestions?

EDIT3/Answer : The answer below explains how to fix the problem – essentially remove any ../ references to Javascript files from the initial site creation/includes. I hope that this helps anyone else who has this problem!

Thanks in Advance,

Paul Hutson

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:32:39+00:00Added an answer on May 19, 2026 at 2:32 am

    Having tried a number of things I have discovered that if any file has a ../ before it (in an include on any page) it will cause the URL Routing problem described above.

    Simply making sure that no file was referenced using ../ solved the problem entirely – specifically it was the Javascript files that were causing the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.