我得到一个“不实现IController” MVC2中的图像和robots.txt错误 [英] I'm getting a "Does not implement IController" error on images and robots.txt in MVC2
问题描述
这是一个例子,我的网络服务器似乎是一个奇怪的错误。只需用任何.jpg名称或.gif替换'/robots.txt',或者你会得到以下想法:
控制器对于路径/robots.txt
未找到或不实现
IController。
确保这与我如何设置路由有关,但我不知道我需要做什么。
此外,这是一个混合的MVC和WebForms网站,如果这有所作为。
您可以忽略robots.txt和路由中的所有aspx页面。
routes.IgnoreRoute({* allaspx},新的{allaspx = @。* \.aspx(/。 *)})?;
routes.IgnoreRoute({* robotstxt},新{robotstxt = @(。* /)?robots.txt(/.*)?});
您可能也想忽略图标。
routes.IgnoreRoute({* favicon},new {favicon = @(。* /)?favicon.ico(/.*)?});
您可以调整正则表达式以排除路径。
从来源。
I'm getting a strange error on my webserver for seemingly every file but the .aspx files.
Here is an example. Just replace '/robots.txt' with any .jpg name or .gif or whatever and you'll get the idea:
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.
Also, this is a mixed MVC and WebForms site, if that makes a difference.
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(/.*)?"});
You might want to ignore the favicon too.
routes.IgnoreRoute("{*favicon}", new {favicon=@"(.*/)?favicon.ico(/.*)?"});
You can adjust the regular expression to exclude paths.
Haacked from the source.
这篇关于我得到一个“不实现IController” MVC2中的图像和robots.txt错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!