Asp.Net System.Web.Routing won't route URL unless .aspx in on the end

微笑、不失礼 提交于 2019-12-22 10:44:51

问题


I have a weird problem with routing. I have an existing website that I am trying to add this to. It works, but only if .aspx is on the end of the URL. If I remove the .aspx, it gives me an error: "The resource cannot be found." I created a quick test website and copied the code over to it, it works just fine. The code between the 2 are identical. Both are running on the VS 2008 web server. I just don't get it. Any ideas?

Thanks, Vincent


回答1:


Okay, I found the problem. I don't understand why this caused the problem, but if there is a period (.) anywhere in the URL, it errors.

I had this: http://localhost:49463/site.dev/products/keylessentrykits

When I changed it to: http://localhost:49463/sitedev/products/keylessentrykits, removing the period between site and dev, it worked fine.

Anyone have a clue to why this is? Is it a bug?

Also, I should have said something before, but this is not an MVC app.




回答2:


I think you need to set the ISAPI dll to handle all files (i.e. add a wildcard). It's working because it's set to handle .aspx.




回答3:


Thank you kindly for finding the solution and posting it. I have been suffering from the exact same issue and have been trying to get it resolved for days now!

My solution contains several projects: web, business logic, data access, etc. My web project was called "SystemName.WebForms" and when I was compiling and running from Visual Studio's debugging environment only routes that contained a period were being routed properly. Once I renamed my web project to "SystemName_WebForms" all of the routes were processed properly. I highly suspect this is a bug that you discovered.

Many thanks for finding the workaround and having the generosity to post it!

MomentSurfer



来源:https://stackoverflow.com/questions/1337029/asp-net-system-web-routing-wont-route-url-unless-aspx-in-on-the-end

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