Wordpress Blog type Permalink in MVC(Custom URL Routing)

admin

Administrator
Staff member
I am facing a issue in my current project where I want to display custom URl for my pages. I have tried lot of techniques but none of them fulfills my requirement.
I want URL like this:

<pre class="lang-none prettyprint-override">
Code:
http://www.anyDomain.com/What-Is-Your-Name

Currently, I am able to set the URL like this:

<pre class="lang-none prettyprint-override">
Code:
http://www.anyDomain.com/What-Is-Your-Name?Id=1

I want to ignore Querystring from URL. So that Controller can identify the request &amp; respond accordingly.

Here,
Code:
Id
is used to fetch details from Database. How can I pass the Parameter Value from
Code:
View
to
Code:
Controller
so It can identify the request without adding it in URL?

My Controller

Code:
[Route("~/{CategoryName}")]
public ActionResult PropertyDetails(int Id)
{
}

RouteConfig

Code:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}",
    defaults:
    new
    {
        controller = "Home",
        action = "Index",

    }
);

My View

Code:
&lt;a href="@Url.Action("PropertyDetails", "Home", new {@Id=item.ID,@CategoryName = Item.Title })"&gt;

<hr>

I just Noticed, I want URL like StackOverflow is using

<pre class="lang-none prettyprint-override">
Code:
http://stackoverflow.com/questions/43774917/wordpress-blog-type-permalink-in-mvccustom-url-routing