.net - URL Rewriting in ASP.Net MVC 2 -
i have written below code achieve url rewriting.
in global.asax
routes.maproute( "studentdetail", // route name "studentdetail", // url parameters new { controller = "udashboard", action = "uaboutmestudentdetails", sortfield = urlparameter.optional } );
in view
<a href="/studentdetail?sortfield='major'" >students</a>
when click link, goes action of controller perfect.
but url
https://localhost/studentdetail?sortfield='major'
and don't want that.
i want url
https://localhost/studentdetail
can please tell me change should achieve above url.
thanks, prashant
if want value of sortfield major, not show in url, need this:
routes.maproute( "studentdetail", // route name "studentdetail", // url parameters new { controller = "udashboard", action = "uaboutmestudentdetails", sortfield = "major" } );
but, if major showing in url, means when generating links passing helper somehow. need make sure remove helper. if still want accept field, default major, this:
routes.maproute( "studentdetail", // route name "studentdetail/{sortfield}", // url parameters new { controller = "udashboard", action = "uaboutmestudentdetails", sortfield = "major" } );
Comments
Post a Comment