I'm getting a “Does not implement IController” error on images and robots.txt in MVC2

后端 未结 6 2219
滥情空心
滥情空心 2020-12-04 09:12

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 .gi

6条回答
  •  伪装坚强ぢ
    2020-12-04 09:28

    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.

提交回复
热议问题