I have a table with which I want to make a catalog.
My table is like this:
Id Product Description Price
I’m going to make an index where I list all the products with their name and they link me with a link to a view where I have their description, I know how to do all that, but I do not know how to make each link of the index automatically or generically received the driver for example:
<a href="https://example.tld/product/id/name-of-product">name of product</a>
I do not think I have to create a controller name-of-product and another other-name-of-product I imagine that there is something generic where I send the controller product accion index
example: ProductController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MySite.Controllers
{
public class ProductyController: Controller
{
// GET: Product
public ActionResult Index (int id, string productstring)
{
return Content (productstring + "example fooo bar ..");
// or
return View ("my_generic_view_styled_css.cshtml");
}
}
}
so that when you put https://example.tld/product/id/foo-bar-any
I returned my index.cshtml with my info I know how to fill it but what I do not know how to do with the urls for SEO
My problem is not to create the index with the links, the problem is that by clicking or going to the url directly there is no error 404
2
Answers
The final solution was the following in case someone serves you
Other trick is call
Just after of
In RouteConfig.cs
It seems you have a routing issue.
How does this seem:
This will decode the parts of the url into the separate parts you require.