I am implementing URL routing in my asp .net 4.0 application.
I have a hyperlink which redirects to another page with some parameters .
Everything is fine until the first page load,I am able to get the values and page is loaded well ,after that my page is being loaded again and this time I am having my application folder names in RouteData.Values .
Can anyone explain this
In Global asax file My route is as follows
RouteTable.Routes.MapPageRoute("CategoryCodesListView", "CategoryCodesListView/{CatRefID}/{HasSubCat}", "~/CategoryList.aspx");
My redirecting Page Code
HyperLink linkItem = (HyperLink)e.Row.FindControl("linkItem");
RouteValueDictionary parameters =
new RouteValueDictionary
{
{"CatRefID",RefCodeSysID },
{ "HasSubCat",lblHasSubCategory.Text }
};
VirtualPathData vpd = RouteTable.Routes.GetVirtualPath(null, "CategoryCodesListView", parameters);
linkItem.NavigateUrl = vpd.VirtualPath;
And my recieving page code is string CatRefID= Convert.ToString(Page.RouteData.Values["CatRefID"])
Lets say I passed
CatRefID="Cat1" and HasSubCat="true";
for the first page load I am getting the same values.
but after the page loaded then the page is loading again and now My values are
CatRefID="Scripts" and HasSubCat="validations.js";
Where Scripts is one of folder name in my application and validations.js is a file in it.
Do you have a link to Scripts folder in your page? If you do, you should correct the address of your scripts that have a link to it. You should use
Ignore
in yourGlobal.asax
or give an absolute address to your links or upload your scripts and use them as: