I want to implement a SEO friendly URL for my ASP.NET Core Razor Page website.
Currently i have a URL like:
http://www.example.com/Post/{PostId}
but now i want to rewrite my URL like:
http://www.example.com/Post/{PostName} Or http://www.example.com/Post/{PostId}/{PostName}
So please anybody can help me on above...
Post.chtml :
@page "{id}/{postName}"
@using KianHyd.Web.Models.Services
@inject PostServices _PostServices
@{
var id = int.Parse((string)RouteData.Values["id"]);
var post = await _PostServices.GetPostById(id);
ViewData["Title"] = post.Name;
}
http://www.example.com/Post/{PostId}, i' ll want redirect tohttp://www.example.com/Post/{PostId}/{PostName}. i use Razor Pages in ASP.NET Core