Reputation: 35
I have 2 MVC projects. One of them is API and I want from this one to pass data into another project in the same solution. How is it possible?
I have added the reference in the head of the controller
public class ProspectController : Controller
{
DataContext db = new DataContext();
// GET: Prospect
public ActionResult Index()
{
Database.SetInitializer(
new MigrateDatabaseToLatestVersion<DataContext, Configuration>());
// The Controller in the other project
TestController t = new TestController();
//return to the Controller in the other project
RedirectToAction("Index", "Project2.TestController", new {id=4});
}
}
Upvotes: 2
Views: 3066
Reputation: 18155
The short answer is that you can't do what you are trying to do. RedirectToAction
uses the route table to create the URL, which you can't do because you're dealing with two different applications and two different route tables.
What you can do is use the RedirectResult
to send the user to another URL entirely, whether it be in the same application or a different one.
return Redirect("http://OtherSite/Test/Index?id=4");
Upvotes: 7