简体   繁体   中英

asp.net MapPageRoute loading page twice

Not sure whats going on, but I have a rewrite with two parameters. For some reason the page is loading twice when it's called. I know that it's the rewrite because it works fine when it's just one parameter. Thanks for any help.

This is in my Global.asax

 routeCollection.MapPageRoute("RouteForAlbum", "album/{autoID}/{albumName}", "~/SitePages/AlbumView.aspx");

This is on my page load

if (!Page.IsPostBack)
{
    string id = Page.RouteData.Values["autoID"].ToString();
    string albuname = Page.RouteData.Values["albumName"].ToString();
}

Wow, found the answer after more searching. If you have javascript reference with ../ this causes issues with URL rewritting. asp.net Multiple Page_Load events for a user control when using URL Routing

UDPATE:

This can also happen when using CSS3PIE together with ASP.net Routing and the two don't play nicely together.

Any CSS3PIE css styles with a URL in the value can cause the target page to execute the code behind multilple times. For me specifically, it was these two lines:

  • behavior: url(PIE.htc);
  • -pie-background: url(bg-image.png) no-repeat, linear-gradient(#FFFFFF, #53A9FF);

Changing the above two lines to start with a leading slash "/" fixed it along with specifying the whole path to the files.

  • behavior: url(/scripts/PIE-1.0.0/PIE.htc);
  • -pie-background: url(/scripts/PIE-1.0.0/bg-image.png) no-repeat, linear-gradient(#FFFFFF, #53A9FF);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM