I am currently trying to figure out how to change my blog's url rules.
Right now the URLs are /Blog/Details/1 but I read that it is a better SEO practice to make the URL /Blog/Details/Post-Title. I have created an extra field in my blog database labeled FriendlyUrl, and when I create a blog entry I replace spaces with dashes (-) but now I have no idea how to make my app work properly.
I was told to look to my global.asx.cs but this is what mine looks like.
public class MvcApplication : HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
}
}
Here is my controller code for details
public ActionResult Details(int id = 0)
{
Blog blog = _db.Blogs.Find(id);
if (blog == null)
{
return HttpNotFound();
}
return View(blog);
}
and here is the link currently being used to link to a blog entry.
<a href="@Url.Action("Details", "Blog", new { id=item.Id})">@Html.DisplayFor(modelItem => item.Title)</a>
Thanks in advance for any help.