当路线的 ID 部分包含句号时,MVC3 给出页面未找到错误
我在 ASP.NET MVC3 中创建了一个基于目录的网站,当您浏览该网站时,您会看到类似 的页面http://server/domains/details/mydomain.coop。
网站的其余部分工作正常,但是当您访问此网址时,您会收到页面未找到错误。我已登录到控制器,并且控制器中的操作未触发。它在我的本地计算机(VS2010 / W7)上运行良好,但是当它被放到实时服务器(MS 2003 服务器 IIS6)上时,它就崩溃了。
如果 url 不包含“.”在最终的域名部分中(在默认路由上传递到可选参数“id”的位,然后一切正常。
有人知道我可以做什么,因为我真的想要 id 部分中的“.”对于 SEO
非常感谢
乔纳森
I have created a directory based site in ASP.NET MVC3 which when you navigate through the site you get to a page like http://server/domains/details/mydomain.coop.
The rest of the site works fine however when you go to this url you get a page not found error. I have put logging in to the controllers and the action in the controller is not fired. It works fine on my local machine (VS2010 / W7) but when it it is put on to the live servers (MS 2003 server IIS6) it breaks.
If the url does not contain the "." in the final domain name part (the bit that is passed through to the optional parm "id" on the default route then it all works.
Does anybody have any ideas what I can do as I really want the "." in the id part for SEO
Many thanks
Jonathan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
-
使您的网址类似于http://server/domains/details/mydomain-coop
。我不确定 SEO 的影响,但我无法想象它比更好或更差。
You could use a
-
to make your url likehttp://server/domains/details/mydomain-coop
. I'm not sure of the SEO implications, but I can't imagine it being better or worse than a.
句号和其他标点符号在 URL 中具有非常具体的含义 - 在本例中,它表示文件扩展名,用于确定激活哪些 IIS 模块和过滤器(我总是将这两个混淆)来处理请求。
您应该真正三思而行以这种方式格式化您的网址;像这样的非标准用途不是你的朋友。
推测:
搜索引擎可能会使用
.
后面的部分来确定 MIME 类型,如果它与实际页面内容不匹配,则会降低您的分数,或者可能完全忽略该链接。请注意,例如,Google 根据文件扩展名和 MIME 类型对图像和页面进行不同的索引(尽管更精通 Google 内部黑魔法的人可能会提供更好/更准确的解释。)这里一篇关于让 ASP.NET 忽略某些文件扩展名的好文章,
另请参阅有关类似问题的 SO 问题(注册自定义文件扩展名 - 在本例中为
.coop
)重要的
web.config
条目第二个链接是:我没有有时间对此进行测试,但希望它能让您朝着正确的方向前进。
Periods and other punctuation have a very specific meaning in URLs - in this case, it indicates a file extension, which is used to determine which IIS modules and filters (I always get these two confused) are activated to handle a request.
You should really think twice about formatting your URLs this way; non-standard uses like this are not your friend.
Conjecture:
It's possible that a search engine may use the part after the
.
to determine MIME type, and either ding your score if it doesn't match the actual page content, or it could ignore the link entirely. Note that, for instance, Google indexes images and pages differently based on both file extension and MIME type (though someone more versed in the dark magic of Google's internals may chime in with a better/more accurate explanation.)Here's a nice post on getting ASP.NET to ignore certain file extensions,
See also this SO question about a similar issue (registering custom file extensions - in this case,
.coop
)The important
web.config
entries from the second link are:I haven't had time to test this, but hopefully it'll get you going in the right direction.