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">
Currently, I am able to set the URL like this:
<pre class="lang-none prettyprint-override">
I want to ignore Querystring from URL. So that Controller can identify the request & respond accordingly.
Here,
is used to fetch details from Database. How can I pass the Parameter Value from
to
so It can identify the request without adding it in URL?
My Controller
RouteConfig
My View
<hr>
I just Noticed, I want URL like StackOverflow is using
<pre class="lang-none prettyprint-override">
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 & respond accordingly.
Here,
Code:
Id
Code:
View
Code:
Controller
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:
<a href="@Url.Action("PropertyDetails", "Home", new {@Id=item.ID,@CategoryName = Item.Title })">
<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