同时使用URL路由CSS绑定 [英] CSS bindings while using url routing
问题描述
我在其中我实现URL路由的ASP.NET 4.0应用程序。我在全球ASAX并能够正确地称他们为定义我的路线。
但我的问题是,当我打电话带有参数的路线我的CSS没有正确绑定。
我联系我的css文件在我的母版页如下:
<链路ID =链接1的rel =stylesheet属性类型=文/ CSS的href =〜/ CSS / style.css中=服务器/&GT ;
<链路ID =链路2的rel =stylesheet属性类型=文/ CSS的href =〜/ CSS / menu.css=服务器/>
当我打电话与页面的路径背后在我的页面的源代码如下我的CSS绑定被改变。
<链路ID =链接1的rel =stylesheet属性类型=文/ CSS的href =CSS / style.css文件/>
<链路ID =链路2的rel =stylesheet属性类型=文/ CSS的href =CSS / menu.css/>
和时,有一个路由值
<链路ID =链接1的rel =stylesheet属性类型=文/ CSS的href =../ CSS / style.css文件/>
<链路ID =链路2的rel =stylesheet属性类型=文/ CSS的href =../ CSS / menu.css/>
当我有两个路由值
<链路ID =链接1的rel =stylesheet属性类型=文/ CSS的href =../../ CSS / style.css文件/>
<链路ID =链路2的rel =stylesheet属性类型=文/ CSS的href =../../ CSS / menu.css/>
和以下全球asax.cs code的一块为我工作。
Routes.Ignore({文件夹} / {*} PATHINFO,新文件夹{=我的图片路径});
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" />
AND the following piece of code in global asax.cs worked for me.
Routes.Ignore("{folder}/{*pathInfo}", new { folder = "my images path" });
这篇关于同时使用URL路由CSS绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!