Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Problem calling web api

$
0
0

hi,

I have controller

namespace MyServer.Controllers
{
    public class Status1 : ApiController
    {
        // GET api/<controller>
        [HttpGet]
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }
    }
}

and in WebApiConfig:

namespace MyServer
{
    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: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }
}

When I call form postman

http://localhost:50068/api/Status1 

i get message 

{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:50068/api/Status1'.","MessageDetail":"No type was found that matches the controller named 'Status1'."}

Please help


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>