我得到一个"没有实现一个IController"错误在MVC2图像和的robots.txt [英] I'm getting a "Does not implement IController" error on images and robots.txt in MVC2

查看:209
本文介绍了我得到一个"没有实现一个IController"错误在MVC2图像和的robots.txt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我让我的web服务器一个奇怪的错误看似每一个文件,但.aspx文件。

I'm getting a strange error on my webserver for seemingly every file but the .aspx files.

下面是一个例子。只是任何.JPG名或.gif或任何替换'/robots.txt的',你会得到的想法:

Here is an example. Just replace '/robots.txt' with any .jpg name or .gif or whatever and you'll get the idea:

控制器为路径的/robots.txt
  没有被发现,或者不执行
  一个IController。

The controller for path '/robots.txt' was not found or does not implement IController.

我敢肯定,这是与我如何已经设置路由,但我不知道究竟是什么,我需要做的。

I'm sure it's something to do with how I've setup routing but I'm not sure what exactly I need to do about it.

此外,这是一个混合MVC和WebForms的网站,如果有差别。

Also, this is a mixed MVC and WebForms site, if that makes a difference.

推荐答案

您可以忽略的robots.txt和你的路由中的所有aspx页面。

You can ignore robots.txt and all the aspx pages in your routing.

routes.IgnoreRoute("{*allaspx}", new {allaspx=@".*\.aspx(/.*)?"});
routes.IgnoreRoute("{*robotstxt}", new {robotstxt=@"(.*/)?robots.txt(/.*)?"});

您可能要忽略图标了。

routes.IgnoreRoute("{*favicon}", new {favicon=@"(.*/)?favicon.ico(/.*)?"});

您可以调整的常规前pression排除路径。

You can adjust the regular expression to exclude paths.

Haacked从<一个href=\"http://haacked.com/archive/2008/07/14/make-routing-ignore-requests-for-a-file-extension.aspx\">source.

这篇关于我得到一个&QUOT;没有实现一个IController&QUOT;错误在MVC2图像和的robots.txt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆