0

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;
}
4

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.