简体   繁体   中英

URL routing with parametres causing multiple page loads and retrieving app folders as parametres

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 your Global.asax or give an absolute address to your links or upload your scripts and use them as:

<script src="http://yourDomain.com/scripts/jquery-1.10.0.js"></script>

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