CSS bindings while using url routing

192 Views Asked by At

I have asp .net 4.0 application in which i am implementing url routing. I have defined my routes in global asax and able to call them correctly.

but my problem is when I am calling a route with parameters my css was not binded properly .

I linked my css files as follows in my master page.

       <link id="Link1" rel="stylesheet" type="text/css" href="~/css/style.css" runat="server" />
<link id="Link2" rel="stylesheet" type="text/css" href="~/css/menu.css" runat="server" />

when i am calling a route with a page my css bindings are being changed as follows in my page source behind.

      <link id="Link1" rel="stylesheet" type="text/css" href="css/style.css" />
      <link id="Link2" rel="stylesheet" type="text/css" href="css/menu.css" />

and when there is a route value

      <link id="Link1" rel="stylesheet" type="text/css" href="../css/style.css" />
      <link id="Link2" rel="stylesheet" type="text/css" href="../css/menu.css" />

when i have two route values

    <link id="Link1" rel="stylesheet" type="text/css" href="../../css/style.css" />
    <link id="Link2" rel="stylesheet" type="text/css" href="../../css/menu.css" />
1

There are 1 best solutions below

0
On

AND the following piece of code in global asax.cs worked for me.

     Routes.Ignore("{folder}/{*pathInfo}", new { folder = "my images path" });