0

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.

Nagaraj
  • 221
  • 2
  • 5
  • 21

1 Answers1

0

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>
Mar_a
  • 50
  • 5
  • Ya I have, can you suggest me a way to ignore the scrpt files files in global asax.cs – Nagaraj Aug 14 '13 at 04:42
  • I have added route.RouteExistingFiles = false; to global asax file and that has resolved my multiple page loads. but i am unable to bind the CSS i have tried with adding runat="server" to the links and given them absolute path. still i am not able to bind the CSS to my page . – Nagaraj Aug 14 '13 at 05:54
  • Please try this: `` or even `` – Mar_a Aug 14 '13 at 15:57
  • can you please look at this and help me [css bindings](http://stackoverflow.com/questions/18228553/css-bindings-while-using-url-routing) – Nagaraj Aug 14 '13 at 16:46