Asp.net 4.0 Webforms Routing Javascript Not Works
I'm try to use ASP.NET 4.0 WebForms Routing. Here is my RegisterRoutes function: void RegisterRoutes(RouteCollection routes) { routes.Ignore('{resource}.axd/{*pathInfo
Solution 1:
I have solved my problem! The solution consists of 2 parts. Firstly I changed my scripts definition from
<scripttype="text/javascript"src="../scripts/something.js"></script>
to
<scripttype="text/javascript"src="/../scripts/something.js"></script>
Thanks MilkyWayJoe fot that solution.
Secondly I added Ignore Routing
routes.Ignore("catalog/good/{resource}.axd/{*pathInfo}");
instead of:
routes.Ignore("{resource}.axd/{*pathInfo}");
So my web resources have no more routes on pages like http://mysite.com/catalog/good/41
Also I have script events on the page like http://mysite.com/catalog/good/41/event/seq/1
. To catch all parameters I add to my route rules this
routes.Ignore("catalog/good/{good}/{*query1}");
routes.Ignore("catalog/good/{good}/{query1}/{*query2}");
routes.Ignore("catalog/good/{good}/{query1}/{query2}/{*query3}");
routes.Ignore("catalog/good/{good}/{query1}/{query2}/{query3}/{*query4}");
And don't forget that your Ignore
declarations must be placed before MapPageRoute
declarations:
routes.Ignore("catalog/good/{resource}.axd/{*pathInfo}");
routes.MapPageRoute("GoodInfo", "catalog/good/{good}", "~/GoodInfo.aspx");`enter code here`
Post a Comment for "Asp.net 4.0 Webforms Routing Javascript Not Works"