没有类型发现匹配的控制器 [英] No type was found that matches controller
本文介绍了没有类型发现匹配的控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用网络API来建立我的第一个应用程序,我已经在我无法找到信息的问题绊倒了。
I'm building my first app using web api, and I've stumbled upon a problem that I can not find information on.
使用采样器,以测试其工作:
Using sample controller to test if its working:
public class TestController : ApiController
{
// GET api/test
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
}
WebApiConfig.cs:
WebApiConfig.cs:
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
我每次尝试使用调用服务的http://本地主机:59502 / API /测试
我正在
<Error>
<Message>
No HTTP resource was found that matches the request URI 'http://localhost:59502/api/test'.
</Message>
<MessageDetail>
No type was found that matches the controller named 'test'.
</MessageDetail>
</Error>
有人能指出我究竟做错了什么?
Can someone point out what am I doing wrong?
推荐答案
其实我已经解决了这个问题,现在 - 通过创建新的项目,并在复制所有的类。
现在一切都完美。
I have actually resolved the issue now - by creating new project, and copying all the classes over. Now everything works perfectly.
你试过将其关闭并重新开启?哦..
"Have you tried turning it off and on again?" Oh well..
这篇关于没有类型发现匹配的控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文