Friendly URLs in ASP.NET MVC 6 (ASP.NET Core or ASP.NET5)

Viewed 4560

In my web site I have this kind of URLs:

https://www.mywebsite.com/View/Index/{MongoDbId}

The Controller return a View with the product details.

My product class DTO (just important fields)

public class ProductDto
{
   public string Id {get; set;}
   public string Name {get; set;}
}

In this moment I have a controller called View, and an Index method that process the request, but I would like to have something like this:

https://www.mywebsite.com/v/56b8b8801561e80c245a165c/amazing-product-name

What is the best way to implement this?

I have read about routing in ASP.NET Core (official project on GitHub), but I don't have very clear how to do.

Thanks!!

2 Answers
Related