TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rajesh Gami
81
24.4k
1.3m
In Web API : No action found on Account controller
Aug 21 2020 12:11 AM
I have create web api project and getting error like
<Error>
<Message>No HTTP resource was found that matches the request URI
'https://localhost:44370/Account/validlogin?userName=admin?userPassword=admin'
.</Message>
<MessageDetail>No action was found on the controller
'Account'
that matches the request.</MessageDetail>
</Error>
Here is my Controller code
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Net;
using
System.Net.Http;
using
System.Web.Http;
namespace
WebAPI.Controllers
{
public
class
AccountController : ApiController
{
[HttpGet]
public
HttpResponseMessage ValidLogin(
string
userName,
string
userPassword)
{
if
(userName ==
"admin"
&& userPassword ==
"admin"
)
{
return
Request.CreateResponse(HttpStatusCode.OK, value: TokenManager.GenerateToken(userName));
}
else
{
return
Request.CreateErrorResponse(HttpStatusCode.BadGateway, message:
"User name and password is invalid"
);
}
}
//public string get()
//{
// return "value";
//}
}
}
And WebApiConfig.cs
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web.Http;
namespace
WebAPI
{
public
static
class
WebApiConfig
{
public
static
void
Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name:
"DefaultApi"
,
routeTemplate:
"{controller}/{action}/{id}"
,
defaults:
new
{ id = RouteParameter.Optional }
);
}
}
}
Now I have run project and pass url like
https://localhost:44370/Account/validlogin?userName=admin?userPassword=admin
and getting error like
<Error>
<Message>No HTTP resource was found that matches the request URI
'https://localhost:44370/Account/validlogin?userName=admin?userPassword=admin'
.</Message>
<MessageDetail>No action was found on the controller
'Account'
that matches the request.</MessageDetail>
</Error>
Please give me some suggestion I have tried all like change action name , api route etc.. but not found any solution.
Reply
Answers (
4
)
Profile give error although I install auto mapper ?
select checboxfor to call datepicker with time in jquery?