I have create web api project and getting error like
No HTTP resource was found that matches the request URI 'https://localhost:44370/Account/validlogin?userName=admin?userPassword=admin'. No action was found on the controller 'Account' that matches the request.
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
No HTTP resource was found that matches the request URI 'https://localhost:44370/Account/validlogin?userName=admin?userPassword=admin'. No action was found on the controller 'Account' that matches the request.
Please give me some suggestion I have tried all like change action name , api route etc.. but not found any solution.

Anupam MaitiPosted Aug 21, 2020, 1:33 AM
Rajesh GamiPosted Aug 21, 2020, 3:52 AM
Laxmidhar SahooPosted Aug 21, 2020, 3:26 AM
Rajesh GamiPosted Aug 21, 2020, 12:13 AM