0

I have use two Project under single solution -- PayrollMVC is Name of Solution which contains two Project 1) Payroll 2) Employee when i Login from Payroll and Redirect to Employee Project Controller action than it does not Call Controller Action and Layout of Employee Project ..Please Suggest me How to Map Two project and how to Call Action from one Project to Another and also I Please Tell me What is the issue of not Calling Action and Layout of Employee Project

tereško
  • 58,060
  • 25
  • 98
  • 150
Vishnu patel
  • 3
  • 1
  • 1

1 Answers1

0

One solution to call an action from one solution to the other would be to use Server Transfer in the controller like so:

public ActionResult Whatever()
{
    string url = //...
    Request.RequestContext.HttpContext.Server.TransferRequest(url);
    return Content("success");//Doesn't actually get returned
}

Copied from https://stackoverflow.com/a/20913290/201648

This is useful if you want to quickly transfer a handful of controllers to a page on another website using the same URL, e.g. http://example.com/payroll/foo could show the content http://example.com/employee/foo but still appear at http://example.com/payroll/foo. This solution is quick to implement but also hacky, and it doesn't solve you layout issues (please continue reading about areas below for a complete solution).

In terms of not calling the actions and layout, it's because they're in a different project (so the current project doesn't know about them). For this reason you'd probably want to go to the trouble of setting up areas. There is a full guide for areas here:

https://msdn.microsoft.com/en-us/library/ee671793%28v=vs.100%29.aspx

You can setup shared layouts for areas as described in this link: http://brockallen.com/2012/08/31/sharing-a-single-_viewstart-across-areas-in-asp-net-mvc/

All the routes (for the controllers) can be configured centrally. I'd start by looking at Registering Area Routes and Linking Between Areas from the first link I posted.

Community
  • 1
  • 1
Aaron Newton
  • 2,124
  • 1
  • 28
  • 31