Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I'm working on an MVC4 Web API project that has site controllers and API controllers. How do I send a request to an API controller from one of the site controllers?

This is my REST API Controller.
XML
public class ApplicationsController : ApiController
   {      
       [HttpGet]
       public Guid GetID(string name)
       {
       }
    }

This is my site Action Controller.
 public class DemoViewController : Controller
    {   
       [HttpGet]   
        public ActionResult GetID()
        {
            return View();
        }
Above Site action Controller is to used inside the Areas and My API Controllers to be used out side of Areas
Posted
Updated 29-Jan-13 3:46am
v2
Comments
Jameel VM 29-Jan-13 9:00am    
What you have tried?ActionLink?
Karthikeyan Mathiyalagan 29-Jan-13 9:18am    
i tried to action link..

Please specify the area in your ActionLink like below
C#
@Html.ActionLink("Admin", "Index", "Meets", new { area = "Admin" }, null)


Hope this helps
 
Share this answer
 
Comments
Karthikeyan Mathiyalagan 29-Jan-13 9:49am    
@jemi, my APIControllers are used out side of Areas. now how to send the request from areas site action controller.
Jameel VM 29-Jan-13 10:04am    
then use like this @Html.ActionLink("Admin", "Index", "Meets", new { area = "" }, null)
Karthikeyan Mathiyalagan 29-Jan-13 15:13pm    
i need to call api controller in page load?
Jameel VM 29-Jan-13 23:57pm    
In MVC there is no pageLoad?Where you want to reDirect and From?
Karthikeyan Mathiyalagan 30-Jan-13 12:29pm    
now i need to call server side to call api controller.
Try this.
You can call an action outside in the Area
C#
@Html.ActionLink("GetId", "Application", new { area = "" }) 


Call action inside of an area

C#
@Html.ActionLink("GetId", "Api", new { area = "SpecifyYourAreaName" }) 

Hope this helps
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900