I have created a web api in mvc 4. my controller is-
[HttpPost]
public string signIn(string socialId, string email)
{
try
{
using (TourismModelContainer db = new TourismModelContainer())
{
var user = (from log in db.UserDetails
where ((log.FacebookId == socialId || log.GoogleId == socialId) && log.IsActive==true)
select new { log.Id, log.Mobile, log.Gender, log.Country }).FirstOrDefault();
if (user != null)
{
string json = new Utills().ObjectToJson(user); ;
if (email == null || email == "")
{
return json;
}
else
{
bool isEmail = db.UserDetails.Where(o=>o.IsActive==true).Any(obj => obj.Email == email);
if (isEmail)
return "1";
else
return json;
}
}
else
{
return "-1";
}
}
}
catch (Exception ex)
{
return "";
}
}
my WebApiConfig.cs file is
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
and my route config is -
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "api/{controller}/{action}/{id}",
defaults: new { id = UrlParameter.Optional }
);
}
but when i call this sign in service, I get following error-
{ "Message": "No HTTP resource was found that matches the request URI 'http://localhost:58851/api/UpTourism/signIn'.", "MessageDetail": "No action was found on the controller 'UpTourism' that matches the request." }
Please help me regarding this.