To get the web API in the MVC3 project, make the following changes:
1. MVC3 .Net 4.
2 - -API - Microsoft.AspNet.WebApi -Version 4.0.30506
3. Global.asax using System.Web.Http; -
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
4. .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
namespace MvcApplication2.Controllers
{
public class ValuesController : ApiController
{
public string Get()
{
return "1";
}
}
}
5. URL- - /api/values . , -API.