CSS bindings while using url routing

2019-09-09 05:47发布

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条回答
走好不送
2楼-- · 2019-09-09 06:14

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

     Routes.Ignore("{folder}/{*pathInfo}", new { folder = "my images path" });
查看更多
登录 后发表回答