0
I have the following URL
/vlog/usertimeline/? Slug=tests
for the Vlog controller, usertimeline action and Slug parameter. How should I set the route to stay
/vlog/usertimeline/tests
I’m using MVC 4.
I have the following routes configured:
routes.MapRoute(
"PubServices",
"PubServices/{action}",
new { controller = "PubServices", action = "Index" });
routes.MapRoute(
"MailsJson",
"MailsJson/{action}",
new { controller = "MailsJson", action = "Index" });
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
routes.MapRoute(
"Company", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Company", action = "Index", id = "" } // Parameter defaults
);
routes.MapRoute(
"RecoverPasswordFinish",
"Account/RecoverPasswordFinish/{username}/{hash}",
new { Controller = "AccountWF", action = "RecoverPasswordFinish" }
);
routes.MapRoute(
"EmailConfirmation",
"AccountWF/EmailConfirmation/{username}/{userid}",
new { Controller = "AccountWF", action = "EmailConfirmation" }
);
routes.MapRoute(
"UnsubscribeBulkEmail",
"Mails/UnsubscribeBulkEmail/{id}",
new { Controller = "Mails", action = "UnsubscribeBulkEmail", id = "" }
);
routes.MapRoute(
"VlogTimeline",
"Vlog/Timeline/{slug}",
new { controller = "Vlog", action = "Timeline", slug = "" }
);
set up some route?
– novic
for this controller I have nothing. there are some routes to other controllers/methods, but they were already in the project I am working on.
– ihavenokia
will have to create a route so that he can do this, and also check the sets of routes if there are no equal. how to put the route file in your question? and the respective controller/action ?
– novic
Unfortunately I cannot paste the code here, since it is a product that is not exclusively mine. What is the logic that is used to hide this Slug? my method is like this:
public ActionResult usertimeline(string slug = "")
– ihavenokia
Without sharing the code it is difficult to help, but try using the [Route("")] attributes to configure.
– Gabriel Coletta
You can use it as a base: Routes.Maproute( "Company", // Route name "{controller}/{action}/{Slug}", // URL with Parameters new { controller = "Company", action = "Index", id = "" } // Parameter defaults&#xTo; );
– DiegoSantos