Returning action route of another MVC project

I am currently creating an administrative tool for a new project that I would like to use to fetch a url from another project in my solution.

Although the product controller does not exist in the project from which I am calling it, I would like to get it from the first project.

Is this possible, or do I need to create some kind of helper method in the first project ?!

Thank you very much in advance.

Update for clarity

For example, let's say that I am creating a Sitemap generator. Let's say I have a route in my first project:

routes.MapRoute(
  "Product",
  "products/{Title}-{Id}",
  new { controller = "Product", action = "Details" }
);

      

And let's say I have a product called "Buzz Cola" with ID 8. This will create a URL:

products/buzz_cola-8  (title has been cleaned, but constraints are not shown here)

      

So, in my second project, there is no Product route and no Product Controller, but I would like to create it in a function that will do something like this:

IEnumerable<ProductInfo> products = MyServiceLayer.GetAllProducts();
List<string> productUrls
foreach(ProductInfo productInfo in products)
{
  productUrls.Add(
    FirstProject.Action("Details", "Product", new { Title = CleanTitle(productInfo.Title), Id = ProductInfo.Id });
  );
}

      

At the end of this, the productUrls will contain something like:

products/slurm_cola-1
products/hotdogs-2
products/squishy-3
products/buzz_cola-8

      

0


a source to share


1 answer


you can create a controller that inherits from the controller in the second project



0


a source







All Articles