CSS bindings while using url routing

拜拜、爱过 提交于 2019-12-11 14:56:39

问题


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:


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

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


来源:https://stackoverflow.com/questions/18228553/css-bindings-while-using-url-routing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!