为文件css js和jpg实现WebForms asp.net 4.0错误404的路由 [英] Implemented Routing for WebForms asp.net 4.0 error 404 for files css js and jpg
问题描述
我已经在我的网站上实现了路由,几乎一切正常,但我收到任何包含的错误消息,因为路径错误导致路由。
我试着更清楚并显示我的代码。
从我的主页链接开始
< a href =search / shose /title => < img class =borderBlacksrc =immagini / b5.jpgalt =/>< / a>
比仅为此目的添加的global.asax
Sub Application_Start(ByVal sender As Object,ByVal e As EventArgs)
Me.RegisterRoutes(RouteTable.Routes)
End Sub
Sub RegisterRoutes(ByVal routeCollection As RouteCollection)
routeCollection.Ignore( < span class =code-string> {resource} .css / {* pathInfo})
routeCollection.Ignore( {resource} .axd / {* pathInfo})
routeCollection.MapPageRoute( RouteForpage, search / {typology} / , 〜/ search-by-typology.aspx)
结束 Sub
因为你可以看到我添加了忽略.css文件,但我不知道为什么当我点击上面的链接打开右页但通过开发工具我在页面的任何链接上都看到了很多错误消息404。这是页面内的其中一个
search-by-typology.aspx
< link rel =stylesheethref =modifiedStyle.csstype =text / cssmedia =screen/>
为什么忽略不正常,我错过了什么?
提前感谢您的帮助
>
Hi,
I have implemented routing on my website and almost everything works fine but I get an error message for any include because the path is wrong cause of the routing.
I try to be more clear and show my code.
Starting from my link in my home page
<a href="search/shose/" title="" > <img class="borderBlack" src="immagini/b5.jpg" alt="" /></a>
than in the global.asax just added for the purpose
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Me.RegisterRoutes(RouteTable.Routes)
End Sub
Sub RegisterRoutes(ByVal routeCollection As RouteCollection)
routeCollection.Ignore("{resource}.css/{*pathInfo}")
routeCollection.Ignore("{resource}.axd/{*pathInfo}")
routeCollection.MapPageRoute("RouteForpage", "search/{typology}/", "~/search-by-typology.aspx")
End Sub
as you can see there I added ignore .css file but I don't know why when I click on the link above open the right page but through dev tool I see lots of error messages 404 for any link o my page. this is one of them inside the page
search-by-typology.aspx
<link rel="stylesheet" href="modifiedStyle.css" type="text/css" media="screen" />
why the ignore is not working fine, am I missing something?
Thank you in advance for your help
>
这篇关于为文件css js和jpg实现WebForms asp.net 4.0错误404的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!