No type was found that matches the controller named 'User'
I'm trying to navigate to a page which its URL is in the following format:
localhost:xxxxx/User/{id}/VerifyEmail?secretKey=xxxxxxxxxxxxxxx
I've added a new route in the RouteConfig.cs
file and so my RouteConfig.cs
looks like this:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "VerifyEmail",
url: "User/{id}/VerifyEmail",
defaults: new { controller = "User", action = "VerifyEmail" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index",
id = UrlParameter.Optional }
);
}
}
Unfortunately, when trying to navigate to that URL I get this page:
<Error>
<Message>
No HTTP resource was found that matches the request URI 'http://localhost:52684/User/f2acc4d0-2e03-4d72-99b6-9b9b85bd661a/VerifyEmail?secretKey=e9bf3924-681c-4afc-a8b0-3fd58eba93fe'.
</Message>
<MessageDetail>
No type was found that matches the controller named 'User'.
</MessageDetail>
</Error>
and here is my UserController:
public class UserController : Controller
{
// GET /User/{id}/VerifyEmail
[HttpGet]
public ActionResult VerifyEmail(string id, string secretKey)
{
try
{
User user = UsersBL.Instance.Verify(id, secretKey);
//logger.Debug(String.Format("User %s just signed-in in by email.",
user.DebugDescription()));
}
catch (Exception e)
{
throw new Exception("Failed", e);
}
return View();
}
}
Please tell me what am I doing wrong?
asp.net-mvc asp.net-mvc-4 asp.net-web-api asp.net-mvc-routing asp.net-web-api-routing
add a comment |
I'm trying to navigate to a page which its URL is in the following format:
localhost:xxxxx/User/{id}/VerifyEmail?secretKey=xxxxxxxxxxxxxxx
I've added a new route in the RouteConfig.cs
file and so my RouteConfig.cs
looks like this:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "VerifyEmail",
url: "User/{id}/VerifyEmail",
defaults: new { controller = "User", action = "VerifyEmail" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index",
id = UrlParameter.Optional }
);
}
}
Unfortunately, when trying to navigate to that URL I get this page:
<Error>
<Message>
No HTTP resource was found that matches the request URI 'http://localhost:52684/User/f2acc4d0-2e03-4d72-99b6-9b9b85bd661a/VerifyEmail?secretKey=e9bf3924-681c-4afc-a8b0-3fd58eba93fe'.
</Message>
<MessageDetail>
No type was found that matches the controller named 'User'.
</MessageDetail>
</Error>
and here is my UserController:
public class UserController : Controller
{
// GET /User/{id}/VerifyEmail
[HttpGet]
public ActionResult VerifyEmail(string id, string secretKey)
{
try
{
User user = UsersBL.Instance.Verify(id, secretKey);
//logger.Debug(String.Format("User %s just signed-in in by email.",
user.DebugDescription()));
}
catch (Exception e)
{
throw new Exception("Failed", e);
}
return View();
}
}
Please tell me what am I doing wrong?
asp.net-mvc asp.net-mvc-4 asp.net-web-api asp.net-mvc-routing asp.net-web-api-routing
2
It's strange that the error is returned as XML document. As if you were using ASP.NET Web API which is hijacking this route. Are you using ASP.NET Web API? And if yes, how does its routing definition looks like?
– Darin Dimitrov
Jul 23 '13 at 15:06
Yes I am using ASP.NET Web API and you can see the routing definition above
– elad
Jul 24 '13 at 9:55
6
No, wait a second. You seem to be confusing ASP.NET Web API and ASP.NET MVC. Those are 2 completely different technologies. What you have shown in your question is an ASP.NET MVC route definitions and controllers. ASP.NET Web API uses entirely different stack. ASP.NET Web API controllers derive fromApiController
and not fromController
and do not return ActionResults contrary to what is shown in your question.
– Darin Dimitrov
Jul 24 '13 at 11:07
2
I know that. When you create a WEB API application you get HomeController which inherits from Controller and not ApiController. My problem is not with my WEB API controllers. I get them all to work fine. The problem is that except from the Index method from the HomeController which I can access, all other methods aren't recognized and I get the exception "No type was found that matches the controller named 'User'"
– elad
Jul 25 '13 at 11:57
add a comment |
I'm trying to navigate to a page which its URL is in the following format:
localhost:xxxxx/User/{id}/VerifyEmail?secretKey=xxxxxxxxxxxxxxx
I've added a new route in the RouteConfig.cs
file and so my RouteConfig.cs
looks like this:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "VerifyEmail",
url: "User/{id}/VerifyEmail",
defaults: new { controller = "User", action = "VerifyEmail" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index",
id = UrlParameter.Optional }
);
}
}
Unfortunately, when trying to navigate to that URL I get this page:
<Error>
<Message>
No HTTP resource was found that matches the request URI 'http://localhost:52684/User/f2acc4d0-2e03-4d72-99b6-9b9b85bd661a/VerifyEmail?secretKey=e9bf3924-681c-4afc-a8b0-3fd58eba93fe'.
</Message>
<MessageDetail>
No type was found that matches the controller named 'User'.
</MessageDetail>
</Error>
and here is my UserController:
public class UserController : Controller
{
// GET /User/{id}/VerifyEmail
[HttpGet]
public ActionResult VerifyEmail(string id, string secretKey)
{
try
{
User user = UsersBL.Instance.Verify(id, secretKey);
//logger.Debug(String.Format("User %s just signed-in in by email.",
user.DebugDescription()));
}
catch (Exception e)
{
throw new Exception("Failed", e);
}
return View();
}
}
Please tell me what am I doing wrong?
asp.net-mvc asp.net-mvc-4 asp.net-web-api asp.net-mvc-routing asp.net-web-api-routing
I'm trying to navigate to a page which its URL is in the following format:
localhost:xxxxx/User/{id}/VerifyEmail?secretKey=xxxxxxxxxxxxxxx
I've added a new route in the RouteConfig.cs
file and so my RouteConfig.cs
looks like this:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "VerifyEmail",
url: "User/{id}/VerifyEmail",
defaults: new { controller = "User", action = "VerifyEmail" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index",
id = UrlParameter.Optional }
);
}
}
Unfortunately, when trying to navigate to that URL I get this page:
<Error>
<Message>
No HTTP resource was found that matches the request URI 'http://localhost:52684/User/f2acc4d0-2e03-4d72-99b6-9b9b85bd661a/VerifyEmail?secretKey=e9bf3924-681c-4afc-a8b0-3fd58eba93fe'.
</Message>
<MessageDetail>
No type was found that matches the controller named 'User'.
</MessageDetail>
</Error>
and here is my UserController:
public class UserController : Controller
{
// GET /User/{id}/VerifyEmail
[HttpGet]
public ActionResult VerifyEmail(string id, string secretKey)
{
try
{
User user = UsersBL.Instance.Verify(id, secretKey);
//logger.Debug(String.Format("User %s just signed-in in by email.",
user.DebugDescription()));
}
catch (Exception e)
{
throw new Exception("Failed", e);
}
return View();
}
}
Please tell me what am I doing wrong?
asp.net-mvc asp.net-mvc-4 asp.net-web-api asp.net-mvc-routing asp.net-web-api-routing
asp.net-mvc asp.net-mvc-4 asp.net-web-api asp.net-mvc-routing asp.net-web-api-routing
edited Oct 30 '15 at 5:19
Shimmy
49.8k101335545
49.8k101335545
asked Jul 23 '13 at 13:09
eladelad
3041414
3041414
2
It's strange that the error is returned as XML document. As if you were using ASP.NET Web API which is hijacking this route. Are you using ASP.NET Web API? And if yes, how does its routing definition looks like?
– Darin Dimitrov
Jul 23 '13 at 15:06
Yes I am using ASP.NET Web API and you can see the routing definition above
– elad
Jul 24 '13 at 9:55
6
No, wait a second. You seem to be confusing ASP.NET Web API and ASP.NET MVC. Those are 2 completely different technologies. What you have shown in your question is an ASP.NET MVC route definitions and controllers. ASP.NET Web API uses entirely different stack. ASP.NET Web API controllers derive fromApiController
and not fromController
and do not return ActionResults contrary to what is shown in your question.
– Darin Dimitrov
Jul 24 '13 at 11:07
2
I know that. When you create a WEB API application you get HomeController which inherits from Controller and not ApiController. My problem is not with my WEB API controllers. I get them all to work fine. The problem is that except from the Index method from the HomeController which I can access, all other methods aren't recognized and I get the exception "No type was found that matches the controller named 'User'"
– elad
Jul 25 '13 at 11:57
add a comment |
2
It's strange that the error is returned as XML document. As if you were using ASP.NET Web API which is hijacking this route. Are you using ASP.NET Web API? And if yes, how does its routing definition looks like?
– Darin Dimitrov
Jul 23 '13 at 15:06
Yes I am using ASP.NET Web API and you can see the routing definition above
– elad
Jul 24 '13 at 9:55
6
No, wait a second. You seem to be confusing ASP.NET Web API and ASP.NET MVC. Those are 2 completely different technologies. What you have shown in your question is an ASP.NET MVC route definitions and controllers. ASP.NET Web API uses entirely different stack. ASP.NET Web API controllers derive fromApiController
and not fromController
and do not return ActionResults contrary to what is shown in your question.
– Darin Dimitrov
Jul 24 '13 at 11:07
2
I know that. When you create a WEB API application you get HomeController which inherits from Controller and not ApiController. My problem is not with my WEB API controllers. I get them all to work fine. The problem is that except from the Index method from the HomeController which I can access, all other methods aren't recognized and I get the exception "No type was found that matches the controller named 'User'"
– elad
Jul 25 '13 at 11:57
2
2
It's strange that the error is returned as XML document. As if you were using ASP.NET Web API which is hijacking this route. Are you using ASP.NET Web API? And if yes, how does its routing definition looks like?
– Darin Dimitrov
Jul 23 '13 at 15:06
It's strange that the error is returned as XML document. As if you were using ASP.NET Web API which is hijacking this route. Are you using ASP.NET Web API? And if yes, how does its routing definition looks like?
– Darin Dimitrov
Jul 23 '13 at 15:06
Yes I am using ASP.NET Web API and you can see the routing definition above
– elad
Jul 24 '13 at 9:55
Yes I am using ASP.NET Web API and you can see the routing definition above
– elad
Jul 24 '13 at 9:55
6
6
No, wait a second. You seem to be confusing ASP.NET Web API and ASP.NET MVC. Those are 2 completely different technologies. What you have shown in your question is an ASP.NET MVC route definitions and controllers. ASP.NET Web API uses entirely different stack. ASP.NET Web API controllers derive from
ApiController
and not from Controller
and do not return ActionResults contrary to what is shown in your question.– Darin Dimitrov
Jul 24 '13 at 11:07
No, wait a second. You seem to be confusing ASP.NET Web API and ASP.NET MVC. Those are 2 completely different technologies. What you have shown in your question is an ASP.NET MVC route definitions and controllers. ASP.NET Web API uses entirely different stack. ASP.NET Web API controllers derive from
ApiController
and not from Controller
and do not return ActionResults contrary to what is shown in your question.– Darin Dimitrov
Jul 24 '13 at 11:07
2
2
I know that. When you create a WEB API application you get HomeController which inherits from Controller and not ApiController. My problem is not with my WEB API controllers. I get them all to work fine. The problem is that except from the Index method from the HomeController which I can access, all other methods aren't recognized and I get the exception "No type was found that matches the controller named 'User'"
– elad
Jul 25 '13 at 11:57
I know that. When you create a WEB API application you get HomeController which inherits from Controller and not ApiController. My problem is not with my WEB API controllers. I get them all to work fine. The problem is that except from the Index method from the HomeController which I can access, all other methods aren't recognized and I get the exception "No type was found that matches the controller named 'User'"
– elad
Jul 25 '13 at 11:57
add a comment |
13 Answers
13
active
oldest
votes
In my case after spending almost 30 minutes trying to fix the problem, I found what was causing it:
My route defined in WebApiConfig.cs
was like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "{controller}/{action}"
);
and it should be like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
as you see it was interfering with the standard route defined in RouteConfig.cs
.
4
Thank you, spent an hour on this!!
– Mike
May 14 '15 at 12:59
2
I'm facing the same issue, except by me the routes are already define the way you suggest.
– Shimmy
Oct 30 '15 at 5:16
3
In my case I updated route template from "api/{controller}/{id}" to "api/{controller}/{action}/{id}" and it worked.
– Ravi Khambhati
Mar 9 '16 at 18:30
2
Had exactly the same issue with interfering configs. Thank you!
– Hinrich
Nov 3 '16 at 11:01
4
In my case was I don't had name 'Controller' in my API class. Convention over configuration.
– JD - DC TECH
Nov 17 '16 at 14:09
|
show 2 more comments
In my case, the controller was defined as:
public class DocumentAPI : ApiController
{
}
Changing it to the following worked!
public class DocumentAPIController : ApiController
{
}
The class name has to end with Controller!
Edit: As @Corey Alix has suggested, please make sure that the controller has a public access modifier; non-public controllers are ignored by the route handler!
3
This trips me up from time to time as well.
– MarkHone
Apr 7 '17 at 13:51
2
OMG!! still cant believe it was it. thx man
– bresleveloper
Sep 16 '17 at 18:05
2
Yep same problem for me. Thanks for this...
– Maxim Gershkovich
Oct 26 '17 at 15:03
2
Problem fixed. Thanks.. :D
– SilentCoder
Dec 20 '17 at 10:19
1
It also needs to be public.
– Corey Alix
Dec 28 '18 at 21:34
|
show 1 more comment
Another solution could be to set the controllers class permission to public.
set this:
class DocumentAPIController : ApiController
{
}
to:
public class DocumentAPIController : ApiController
{
}
1
thankyou so much. i've spent like 10 hours on this and finally you've helped
– l--''''''---------''''''''''''
Nov 7 '17 at 4:12
add a comment |
In my case I was using Web API and I did not have the public
defined for my controller class.
Things to check for Web API:
- Controller Class is declares as
public
- Controller Class implements ApiController
: ApiController
- Controller Class name needs to end in
Controller
- Check that your url has the
/api/
prefix. eg. 'host:port/api/{controller}/{actionMethod}'
add a comment |
In my case I wanted to create a Web API controller, but, because of inattention, my controller was inherited from Controller instead of ApiController.
Great! That was it.
– Francesco B.
Oct 31 '18 at 16:15
add a comment |
In my case, the routing was defined as:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "WarehouseController" }
while Controller needs to be dropped in the config:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "Warehouse" }
That did it for me.
– Adrian K
Oct 10 '17 at 0:56
add a comment |
In my case I was seeing this because I had two controllers with the same name:
One for handling Customer orders called CustomersController
and the other for getting events also called CustomersController
I had missed the duplication, I renamed the events one to CustomerEventsController
and it worked perfectly
add a comment |
Experienced this similar issue. We are dealing with multiple APIs and we were hitting the wrong port number and getting this error. Took us forever to realize. Make sure the port of the api you are hitting is the correct port.
1
It's Really help for me. i was dealing with multiple APIs and we were hitting the wrong. thank dude
– Satish Kumar sonker
Dec 29 '17 at 6:53
You're welcome :)
– Erkin Djindjiev
Jan 4 '18 at 15:35
add a comment |
I have also faced the same problem. I searched a lot and found that the class level permission is needed. by default, the class permission level is internal so I thought that it won't affect the program execution. But it got affected actually, you should give your class permission as public so that, you won't face any problem.
And one more. if it is webapi project, your webapirouteconfig file will overwrite the routeconfig.cs file settings. So update the webapi routeconfig file as well to work properly.
add a comment |
In my solution, I have a project called "P420" and into other project I had a P420Controller.
When .NET cut controller name to find route, conflict with other project, used as a library into.
Hope it helps.
add a comment |
In my solution, when I added the my new Controller to the project, the wizard asked me if I want to set the location of the controller into the App_Code folder.
The wizard warned me, if I do not locate it into the the App_Code folder, the controller type won't be found.
But I didn't read the whole warning, because I wanted to locate the file to elsewhere..
so that's why it didn't work for me.
After I added a new controller and let it to be in the App_Code by default, everything worked.
add a comment |
Faced the same problem. Checked all the answers here but my problem was in namespacing.
Routing attributes exists in System.Web.Mvc and in System.Web.Http. My usings included Mvc namespace and it was the reason. For webapi u need to use System.Net.Http.
add a comment |
In my case I was calling the APi like
http://locahost:56159/api/loginDataController/GetLoginData
while it should be like
http://locahost:56159/api/loginData/GetLoginData
removed Controller from URL and it started working ...
Peace!
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17811142%2fno-type-was-found-that-matches-the-controller-named-user%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
13 Answers
13
active
oldest
votes
13 Answers
13
active
oldest
votes
active
oldest
votes
active
oldest
votes
In my case after spending almost 30 minutes trying to fix the problem, I found what was causing it:
My route defined in WebApiConfig.cs
was like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "{controller}/{action}"
);
and it should be like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
as you see it was interfering with the standard route defined in RouteConfig.cs
.
4
Thank you, spent an hour on this!!
– Mike
May 14 '15 at 12:59
2
I'm facing the same issue, except by me the routes are already define the way you suggest.
– Shimmy
Oct 30 '15 at 5:16
3
In my case I updated route template from "api/{controller}/{id}" to "api/{controller}/{action}/{id}" and it worked.
– Ravi Khambhati
Mar 9 '16 at 18:30
2
Had exactly the same issue with interfering configs. Thank you!
– Hinrich
Nov 3 '16 at 11:01
4
In my case was I don't had name 'Controller' in my API class. Convention over configuration.
– JD - DC TECH
Nov 17 '16 at 14:09
|
show 2 more comments
In my case after spending almost 30 minutes trying to fix the problem, I found what was causing it:
My route defined in WebApiConfig.cs
was like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "{controller}/{action}"
);
and it should be like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
as you see it was interfering with the standard route defined in RouteConfig.cs
.
4
Thank you, spent an hour on this!!
– Mike
May 14 '15 at 12:59
2
I'm facing the same issue, except by me the routes are already define the way you suggest.
– Shimmy
Oct 30 '15 at 5:16
3
In my case I updated route template from "api/{controller}/{id}" to "api/{controller}/{action}/{id}" and it worked.
– Ravi Khambhati
Mar 9 '16 at 18:30
2
Had exactly the same issue with interfering configs. Thank you!
– Hinrich
Nov 3 '16 at 11:01
4
In my case was I don't had name 'Controller' in my API class. Convention over configuration.
– JD - DC TECH
Nov 17 '16 at 14:09
|
show 2 more comments
In my case after spending almost 30 minutes trying to fix the problem, I found what was causing it:
My route defined in WebApiConfig.cs
was like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "{controller}/{action}"
);
and it should be like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
as you see it was interfering with the standard route defined in RouteConfig.cs
.
In my case after spending almost 30 minutes trying to fix the problem, I found what was causing it:
My route defined in WebApiConfig.cs
was like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "{controller}/{action}"
);
and it should be like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
as you see it was interfering with the standard route defined in RouteConfig.cs
.
edited Oct 30 '15 at 5:16
Shimmy
49.8k101335545
49.8k101335545
answered Dec 16 '13 at 15:19
Leniel MaccaferriLeniel Maccaferri
80.3k34287394
80.3k34287394
4
Thank you, spent an hour on this!!
– Mike
May 14 '15 at 12:59
2
I'm facing the same issue, except by me the routes are already define the way you suggest.
– Shimmy
Oct 30 '15 at 5:16
3
In my case I updated route template from "api/{controller}/{id}" to "api/{controller}/{action}/{id}" and it worked.
– Ravi Khambhati
Mar 9 '16 at 18:30
2
Had exactly the same issue with interfering configs. Thank you!
– Hinrich
Nov 3 '16 at 11:01
4
In my case was I don't had name 'Controller' in my API class. Convention over configuration.
– JD - DC TECH
Nov 17 '16 at 14:09
|
show 2 more comments
4
Thank you, spent an hour on this!!
– Mike
May 14 '15 at 12:59
2
I'm facing the same issue, except by me the routes are already define the way you suggest.
– Shimmy
Oct 30 '15 at 5:16
3
In my case I updated route template from "api/{controller}/{id}" to "api/{controller}/{action}/{id}" and it worked.
– Ravi Khambhati
Mar 9 '16 at 18:30
2
Had exactly the same issue with interfering configs. Thank you!
– Hinrich
Nov 3 '16 at 11:01
4
In my case was I don't had name 'Controller' in my API class. Convention over configuration.
– JD - DC TECH
Nov 17 '16 at 14:09
4
4
Thank you, spent an hour on this!!
– Mike
May 14 '15 at 12:59
Thank you, spent an hour on this!!
– Mike
May 14 '15 at 12:59
2
2
I'm facing the same issue, except by me the routes are already define the way you suggest.
– Shimmy
Oct 30 '15 at 5:16
I'm facing the same issue, except by me the routes are already define the way you suggest.
– Shimmy
Oct 30 '15 at 5:16
3
3
In my case I updated route template from "api/{controller}/{id}" to "api/{controller}/{action}/{id}" and it worked.
– Ravi Khambhati
Mar 9 '16 at 18:30
In my case I updated route template from "api/{controller}/{id}" to "api/{controller}/{action}/{id}" and it worked.
– Ravi Khambhati
Mar 9 '16 at 18:30
2
2
Had exactly the same issue with interfering configs. Thank you!
– Hinrich
Nov 3 '16 at 11:01
Had exactly the same issue with interfering configs. Thank you!
– Hinrich
Nov 3 '16 at 11:01
4
4
In my case was I don't had name 'Controller' in my API class. Convention over configuration.
– JD - DC TECH
Nov 17 '16 at 14:09
In my case was I don't had name 'Controller' in my API class. Convention over configuration.
– JD - DC TECH
Nov 17 '16 at 14:09
|
show 2 more comments
In my case, the controller was defined as:
public class DocumentAPI : ApiController
{
}
Changing it to the following worked!
public class DocumentAPIController : ApiController
{
}
The class name has to end with Controller!
Edit: As @Corey Alix has suggested, please make sure that the controller has a public access modifier; non-public controllers are ignored by the route handler!
3
This trips me up from time to time as well.
– MarkHone
Apr 7 '17 at 13:51
2
OMG!! still cant believe it was it. thx man
– bresleveloper
Sep 16 '17 at 18:05
2
Yep same problem for me. Thanks for this...
– Maxim Gershkovich
Oct 26 '17 at 15:03
2
Problem fixed. Thanks.. :D
– SilentCoder
Dec 20 '17 at 10:19
1
It also needs to be public.
– Corey Alix
Dec 28 '18 at 21:34
|
show 1 more comment
In my case, the controller was defined as:
public class DocumentAPI : ApiController
{
}
Changing it to the following worked!
public class DocumentAPIController : ApiController
{
}
The class name has to end with Controller!
Edit: As @Corey Alix has suggested, please make sure that the controller has a public access modifier; non-public controllers are ignored by the route handler!
3
This trips me up from time to time as well.
– MarkHone
Apr 7 '17 at 13:51
2
OMG!! still cant believe it was it. thx man
– bresleveloper
Sep 16 '17 at 18:05
2
Yep same problem for me. Thanks for this...
– Maxim Gershkovich
Oct 26 '17 at 15:03
2
Problem fixed. Thanks.. :D
– SilentCoder
Dec 20 '17 at 10:19
1
It also needs to be public.
– Corey Alix
Dec 28 '18 at 21:34
|
show 1 more comment
In my case, the controller was defined as:
public class DocumentAPI : ApiController
{
}
Changing it to the following worked!
public class DocumentAPIController : ApiController
{
}
The class name has to end with Controller!
Edit: As @Corey Alix has suggested, please make sure that the controller has a public access modifier; non-public controllers are ignored by the route handler!
In my case, the controller was defined as:
public class DocumentAPI : ApiController
{
}
Changing it to the following worked!
public class DocumentAPIController : ApiController
{
}
The class name has to end with Controller!
Edit: As @Corey Alix has suggested, please make sure that the controller has a public access modifier; non-public controllers are ignored by the route handler!
edited Dec 31 '18 at 9:31
answered Feb 3 '16 at 15:12
RaghuRaghu
920913
920913
3
This trips me up from time to time as well.
– MarkHone
Apr 7 '17 at 13:51
2
OMG!! still cant believe it was it. thx man
– bresleveloper
Sep 16 '17 at 18:05
2
Yep same problem for me. Thanks for this...
– Maxim Gershkovich
Oct 26 '17 at 15:03
2
Problem fixed. Thanks.. :D
– SilentCoder
Dec 20 '17 at 10:19
1
It also needs to be public.
– Corey Alix
Dec 28 '18 at 21:34
|
show 1 more comment
3
This trips me up from time to time as well.
– MarkHone
Apr 7 '17 at 13:51
2
OMG!! still cant believe it was it. thx man
– bresleveloper
Sep 16 '17 at 18:05
2
Yep same problem for me. Thanks for this...
– Maxim Gershkovich
Oct 26 '17 at 15:03
2
Problem fixed. Thanks.. :D
– SilentCoder
Dec 20 '17 at 10:19
1
It also needs to be public.
– Corey Alix
Dec 28 '18 at 21:34
3
3
This trips me up from time to time as well.
– MarkHone
Apr 7 '17 at 13:51
This trips me up from time to time as well.
– MarkHone
Apr 7 '17 at 13:51
2
2
OMG!! still cant believe it was it. thx man
– bresleveloper
Sep 16 '17 at 18:05
OMG!! still cant believe it was it. thx man
– bresleveloper
Sep 16 '17 at 18:05
2
2
Yep same problem for me. Thanks for this...
– Maxim Gershkovich
Oct 26 '17 at 15:03
Yep same problem for me. Thanks for this...
– Maxim Gershkovich
Oct 26 '17 at 15:03
2
2
Problem fixed. Thanks.. :D
– SilentCoder
Dec 20 '17 at 10:19
Problem fixed. Thanks.. :D
– SilentCoder
Dec 20 '17 at 10:19
1
1
It also needs to be public.
– Corey Alix
Dec 28 '18 at 21:34
It also needs to be public.
– Corey Alix
Dec 28 '18 at 21:34
|
show 1 more comment
Another solution could be to set the controllers class permission to public.
set this:
class DocumentAPIController : ApiController
{
}
to:
public class DocumentAPIController : ApiController
{
}
1
thankyou so much. i've spent like 10 hours on this and finally you've helped
– l--''''''---------''''''''''''
Nov 7 '17 at 4:12
add a comment |
Another solution could be to set the controllers class permission to public.
set this:
class DocumentAPIController : ApiController
{
}
to:
public class DocumentAPIController : ApiController
{
}
1
thankyou so much. i've spent like 10 hours on this and finally you've helped
– l--''''''---------''''''''''''
Nov 7 '17 at 4:12
add a comment |
Another solution could be to set the controllers class permission to public.
set this:
class DocumentAPIController : ApiController
{
}
to:
public class DocumentAPIController : ApiController
{
}
Another solution could be to set the controllers class permission to public.
set this:
class DocumentAPIController : ApiController
{
}
to:
public class DocumentAPIController : ApiController
{
}
answered Oct 7 '16 at 16:23
ElRaphElRaph
16114
16114
1
thankyou so much. i've spent like 10 hours on this and finally you've helped
– l--''''''---------''''''''''''
Nov 7 '17 at 4:12
add a comment |
1
thankyou so much. i've spent like 10 hours on this and finally you've helped
– l--''''''---------''''''''''''
Nov 7 '17 at 4:12
1
1
thankyou so much. i've spent like 10 hours on this and finally you've helped
– l--''''''---------''''''''''''
Nov 7 '17 at 4:12
thankyou so much. i've spent like 10 hours on this and finally you've helped
– l--''''''---------''''''''''''
Nov 7 '17 at 4:12
add a comment |
In my case I was using Web API and I did not have the public
defined for my controller class.
Things to check for Web API:
- Controller Class is declares as
public
- Controller Class implements ApiController
: ApiController
- Controller Class name needs to end in
Controller
- Check that your url has the
/api/
prefix. eg. 'host:port/api/{controller}/{actionMethod}'
add a comment |
In my case I was using Web API and I did not have the public
defined for my controller class.
Things to check for Web API:
- Controller Class is declares as
public
- Controller Class implements ApiController
: ApiController
- Controller Class name needs to end in
Controller
- Check that your url has the
/api/
prefix. eg. 'host:port/api/{controller}/{actionMethod}'
add a comment |
In my case I was using Web API and I did not have the public
defined for my controller class.
Things to check for Web API:
- Controller Class is declares as
public
- Controller Class implements ApiController
: ApiController
- Controller Class name needs to end in
Controller
- Check that your url has the
/api/
prefix. eg. 'host:port/api/{controller}/{actionMethod}'
In my case I was using Web API and I did not have the public
defined for my controller class.
Things to check for Web API:
- Controller Class is declares as
public
- Controller Class implements ApiController
: ApiController
- Controller Class name needs to end in
Controller
- Check that your url has the
/api/
prefix. eg. 'host:port/api/{controller}/{actionMethod}'
answered Jul 26 '17 at 8:56
ZapnologicaZapnologica
9,04433103189
9,04433103189
add a comment |
add a comment |
In my case I wanted to create a Web API controller, but, because of inattention, my controller was inherited from Controller instead of ApiController.
Great! That was it.
– Francesco B.
Oct 31 '18 at 16:15
add a comment |
In my case I wanted to create a Web API controller, but, because of inattention, my controller was inherited from Controller instead of ApiController.
Great! That was it.
– Francesco B.
Oct 31 '18 at 16:15
add a comment |
In my case I wanted to create a Web API controller, but, because of inattention, my controller was inherited from Controller instead of ApiController.
In my case I wanted to create a Web API controller, but, because of inattention, my controller was inherited from Controller instead of ApiController.
edited Oct 5 '16 at 13:55
answered Jun 3 '16 at 8:05
Sergey_TSergey_T
11927
11927
Great! That was it.
– Francesco B.
Oct 31 '18 at 16:15
add a comment |
Great! That was it.
– Francesco B.
Oct 31 '18 at 16:15
Great! That was it.
– Francesco B.
Oct 31 '18 at 16:15
Great! That was it.
– Francesco B.
Oct 31 '18 at 16:15
add a comment |
In my case, the routing was defined as:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "WarehouseController" }
while Controller needs to be dropped in the config:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "Warehouse" }
That did it for me.
– Adrian K
Oct 10 '17 at 0:56
add a comment |
In my case, the routing was defined as:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "WarehouseController" }
while Controller needs to be dropped in the config:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "Warehouse" }
That did it for me.
– Adrian K
Oct 10 '17 at 0:56
add a comment |
In my case, the routing was defined as:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "WarehouseController" }
while Controller needs to be dropped in the config:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "Warehouse" }
In my case, the routing was defined as:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "WarehouseController" }
while Controller needs to be dropped in the config:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "Warehouse" }
answered Sep 9 '16 at 9:50
JuliuszJuliusz
1,82812022
1,82812022
That did it for me.
– Adrian K
Oct 10 '17 at 0:56
add a comment |
That did it for me.
– Adrian K
Oct 10 '17 at 0:56
That did it for me.
– Adrian K
Oct 10 '17 at 0:56
That did it for me.
– Adrian K
Oct 10 '17 at 0:56
add a comment |
In my case I was seeing this because I had two controllers with the same name:
One for handling Customer orders called CustomersController
and the other for getting events also called CustomersController
I had missed the duplication, I renamed the events one to CustomerEventsController
and it worked perfectly
add a comment |
In my case I was seeing this because I had two controllers with the same name:
One for handling Customer orders called CustomersController
and the other for getting events also called CustomersController
I had missed the duplication, I renamed the events one to CustomerEventsController
and it worked perfectly
add a comment |
In my case I was seeing this because I had two controllers with the same name:
One for handling Customer orders called CustomersController
and the other for getting events also called CustomersController
I had missed the duplication, I renamed the events one to CustomerEventsController
and it worked perfectly
In my case I was seeing this because I had two controllers with the same name:
One for handling Customer orders called CustomersController
and the other for getting events also called CustomersController
I had missed the duplication, I renamed the events one to CustomerEventsController
and it worked perfectly
answered Jan 13 '17 at 16:10
RobertHRobertH
311
311
add a comment |
add a comment |
Experienced this similar issue. We are dealing with multiple APIs and we were hitting the wrong port number and getting this error. Took us forever to realize. Make sure the port of the api you are hitting is the correct port.
1
It's Really help for me. i was dealing with multiple APIs and we were hitting the wrong. thank dude
– Satish Kumar sonker
Dec 29 '17 at 6:53
You're welcome :)
– Erkin Djindjiev
Jan 4 '18 at 15:35
add a comment |
Experienced this similar issue. We are dealing with multiple APIs and we were hitting the wrong port number and getting this error. Took us forever to realize. Make sure the port of the api you are hitting is the correct port.
1
It's Really help for me. i was dealing with multiple APIs and we were hitting the wrong. thank dude
– Satish Kumar sonker
Dec 29 '17 at 6:53
You're welcome :)
– Erkin Djindjiev
Jan 4 '18 at 15:35
add a comment |
Experienced this similar issue. We are dealing with multiple APIs and we were hitting the wrong port number and getting this error. Took us forever to realize. Make sure the port of the api you are hitting is the correct port.
Experienced this similar issue. We are dealing with multiple APIs and we were hitting the wrong port number and getting this error. Took us forever to realize. Make sure the port of the api you are hitting is the correct port.
answered Dec 1 '16 at 23:09
Erkin DjindjievErkin Djindjiev
1215
1215
1
It's Really help for me. i was dealing with multiple APIs and we were hitting the wrong. thank dude
– Satish Kumar sonker
Dec 29 '17 at 6:53
You're welcome :)
– Erkin Djindjiev
Jan 4 '18 at 15:35
add a comment |
1
It's Really help for me. i was dealing with multiple APIs and we were hitting the wrong. thank dude
– Satish Kumar sonker
Dec 29 '17 at 6:53
You're welcome :)
– Erkin Djindjiev
Jan 4 '18 at 15:35
1
1
It's Really help for me. i was dealing with multiple APIs and we were hitting the wrong. thank dude
– Satish Kumar sonker
Dec 29 '17 at 6:53
It's Really help for me. i was dealing with multiple APIs and we were hitting the wrong. thank dude
– Satish Kumar sonker
Dec 29 '17 at 6:53
You're welcome :)
– Erkin Djindjiev
Jan 4 '18 at 15:35
You're welcome :)
– Erkin Djindjiev
Jan 4 '18 at 15:35
add a comment |
I have also faced the same problem. I searched a lot and found that the class level permission is needed. by default, the class permission level is internal so I thought that it won't affect the program execution. But it got affected actually, you should give your class permission as public so that, you won't face any problem.
And one more. if it is webapi project, your webapirouteconfig file will overwrite the routeconfig.cs file settings. So update the webapi routeconfig file as well to work properly.
add a comment |
I have also faced the same problem. I searched a lot and found that the class level permission is needed. by default, the class permission level is internal so I thought that it won't affect the program execution. But it got affected actually, you should give your class permission as public so that, you won't face any problem.
And one more. if it is webapi project, your webapirouteconfig file will overwrite the routeconfig.cs file settings. So update the webapi routeconfig file as well to work properly.
add a comment |
I have also faced the same problem. I searched a lot and found that the class level permission is needed. by default, the class permission level is internal so I thought that it won't affect the program execution. But it got affected actually, you should give your class permission as public so that, you won't face any problem.
And one more. if it is webapi project, your webapirouteconfig file will overwrite the routeconfig.cs file settings. So update the webapi routeconfig file as well to work properly.
I have also faced the same problem. I searched a lot and found that the class level permission is needed. by default, the class permission level is internal so I thought that it won't affect the program execution. But it got affected actually, you should give your class permission as public so that, you won't face any problem.
And one more. if it is webapi project, your webapirouteconfig file will overwrite the routeconfig.cs file settings. So update the webapi routeconfig file as well to work properly.
edited Dec 7 '17 at 7:37
answered Aug 26 '17 at 15:08
Gopi PGopi P
6619
6619
add a comment |
add a comment |
In my solution, I have a project called "P420" and into other project I had a P420Controller.
When .NET cut controller name to find route, conflict with other project, used as a library into.
Hope it helps.
add a comment |
In my solution, I have a project called "P420" and into other project I had a P420Controller.
When .NET cut controller name to find route, conflict with other project, used as a library into.
Hope it helps.
add a comment |
In my solution, I have a project called "P420" and into other project I had a P420Controller.
When .NET cut controller name to find route, conflict with other project, used as a library into.
Hope it helps.
In my solution, I have a project called "P420" and into other project I had a P420Controller.
When .NET cut controller name to find route, conflict with other project, used as a library into.
Hope it helps.
answered Aug 10 '18 at 16:26
Andre MesquitaAndre Mesquita
417415
417415
add a comment |
add a comment |
In my solution, when I added the my new Controller to the project, the wizard asked me if I want to set the location of the controller into the App_Code folder.
The wizard warned me, if I do not locate it into the the App_Code folder, the controller type won't be found.
But I didn't read the whole warning, because I wanted to locate the file to elsewhere..
so that's why it didn't work for me.
After I added a new controller and let it to be in the App_Code by default, everything worked.
add a comment |
In my solution, when I added the my new Controller to the project, the wizard asked me if I want to set the location of the controller into the App_Code folder.
The wizard warned me, if I do not locate it into the the App_Code folder, the controller type won't be found.
But I didn't read the whole warning, because I wanted to locate the file to elsewhere..
so that's why it didn't work for me.
After I added a new controller and let it to be in the App_Code by default, everything worked.
add a comment |
In my solution, when I added the my new Controller to the project, the wizard asked me if I want to set the location of the controller into the App_Code folder.
The wizard warned me, if I do not locate it into the the App_Code folder, the controller type won't be found.
But I didn't read the whole warning, because I wanted to locate the file to elsewhere..
so that's why it didn't work for me.
After I added a new controller and let it to be in the App_Code by default, everything worked.
In my solution, when I added the my new Controller to the project, the wizard asked me if I want to set the location of the controller into the App_Code folder.
The wizard warned me, if I do not locate it into the the App_Code folder, the controller type won't be found.
But I didn't read the whole warning, because I wanted to locate the file to elsewhere..
so that's why it didn't work for me.
After I added a new controller and let it to be in the App_Code by default, everything worked.
answered Sep 4 '18 at 7:49
BeneBene
464
464
add a comment |
add a comment |
Faced the same problem. Checked all the answers here but my problem was in namespacing.
Routing attributes exists in System.Web.Mvc and in System.Web.Http. My usings included Mvc namespace and it was the reason. For webapi u need to use System.Net.Http.
add a comment |
Faced the same problem. Checked all the answers here but my problem was in namespacing.
Routing attributes exists in System.Web.Mvc and in System.Web.Http. My usings included Mvc namespace and it was the reason. For webapi u need to use System.Net.Http.
add a comment |
Faced the same problem. Checked all the answers here but my problem was in namespacing.
Routing attributes exists in System.Web.Mvc and in System.Web.Http. My usings included Mvc namespace and it was the reason. For webapi u need to use System.Net.Http.
Faced the same problem. Checked all the answers here but my problem was in namespacing.
Routing attributes exists in System.Web.Mvc and in System.Web.Http. My usings included Mvc namespace and it was the reason. For webapi u need to use System.Net.Http.
answered Oct 13 '18 at 9:43
Leonid ErshovLeonid Ershov
273
273
add a comment |
add a comment |
In my case I was calling the APi like
http://locahost:56159/api/loginDataController/GetLoginData
while it should be like
http://locahost:56159/api/loginData/GetLoginData
removed Controller from URL and it started working ...
Peace!
add a comment |
In my case I was calling the APi like
http://locahost:56159/api/loginDataController/GetLoginData
while it should be like
http://locahost:56159/api/loginData/GetLoginData
removed Controller from URL and it started working ...
Peace!
add a comment |
In my case I was calling the APi like
http://locahost:56159/api/loginDataController/GetLoginData
while it should be like
http://locahost:56159/api/loginData/GetLoginData
removed Controller from URL and it started working ...
Peace!
In my case I was calling the APi like
http://locahost:56159/api/loginDataController/GetLoginData
while it should be like
http://locahost:56159/api/loginData/GetLoginData
removed Controller from URL and it started working ...
Peace!
answered Dec 24 '18 at 13:52
AzharAzhar
12.5k37125189
12.5k37125189
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17811142%2fno-type-was-found-that-matches-the-controller-named-user%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
It's strange that the error is returned as XML document. As if you were using ASP.NET Web API which is hijacking this route. Are you using ASP.NET Web API? And if yes, how does its routing definition looks like?
– Darin Dimitrov
Jul 23 '13 at 15:06
Yes I am using ASP.NET Web API and you can see the routing definition above
– elad
Jul 24 '13 at 9:55
6
No, wait a second. You seem to be confusing ASP.NET Web API and ASP.NET MVC. Those are 2 completely different technologies. What you have shown in your question is an ASP.NET MVC route definitions and controllers. ASP.NET Web API uses entirely different stack. ASP.NET Web API controllers derive from
ApiController
and not fromController
and do not return ActionResults contrary to what is shown in your question.– Darin Dimitrov
Jul 24 '13 at 11:07
2
I know that. When you create a WEB API application you get HomeController which inherits from Controller and not ApiController. My problem is not with my WEB API controllers. I get them all to work fine. The problem is that except from the Index method from the HomeController which I can access, all other methods aren't recognized and I get the exception "No type was found that matches the controller named 'User'"
– elad
Jul 25 '13 at 11:57