Question

I'm currently creating an admin tool for a new project which I would like to use to retrieve a url from a different project in my solution.

Although the product controller doesn't exist in the project I am calling it from, I would like to retrieve it from the first project.

Is this at all possible, or would I need to create some sort of helper method in the first project?!

Many thanks in advance.

Update for clarity

For example, let's say that I am building 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 that I have product with the title 'Buzz Cola' with an id of 8. This would generate the 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 there is no Product controller, but I'd like to create one in a function that would 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, productUrls would contain something like:

products/slurm_cola-1
products/hotdogs-2
products/squishy-3
products/buzz_cola-8
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top