Redirecting to a content page in ASP.NET C# but page_load is fired multiple times with different urls including JS

43 Views Asked by At

Background

I am developing an e-commerce website in ASP.Net C# (Webforms) that has a main page, that displays recent products. Once the product is clicked, the control is redirected to details page.

Both the main page and details page share the same master page that contains all the javascript references/CDNs. Everything works fine on the main page. Slick slider also works fine. URL stays the same as well on main page e.g. localhost:12345/mainpage.aspx

When a product on main page is clicked, the control is redirected to details page using Response.Redirect. The URL is also modified, product name is attached at the end e.g. localhost:12345/details.aspx/Produt1. No errors are shown

Problem

The details page loads but page load even fires so many time, everytime with a different URL e.g. localhost:12345/details.aspx/js/main.js

/details.aspx/lib/easing/easing.min.js

/details.aspx/lib/slick/slick.min.js

/details.aspx/img/product-7.jpg

/details.aspx/lib/easing/easing.min.js

/details.aspx/img/Logo.png

It even includes the path of logo in URL, but does not display.

The Ask

I would appreciate if anyone can guide me why page loads so many times when there is /Product1 added to URL, and then the javascript doesn't work, slick slider is not working, the logo is not displaying. If I remove everything after details.aspx, it works fine. e.g. localhost:12345/details.aspx

0

There are 0 best solutions below