working on an MVC project and I'm having a tough time with rerouting my URL. What I currently have is
http://dev.mywebsite.com/s/index?Key=abc123
which then runs the index action and completes as I'd like it to I'd like to be able to type in
http://dev.mywebsite.com/s/abc123
and run the index action like normally
I currently have
routes.MapRoute(null, "s/index/{id}", new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional
}
);
but I'm kind of stuck as to where to go from here. Any assistance would be greatly appreciated. Thanks
Edit: My full routeconfig class
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("sites/{*pathInfo}");
routes.MapRoute(null, "s/index/{key}", new
{
controller = "S",
action = "Index",
key = UrlParameter.Optional
}
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Site", action = "Index", id = UrlParameter.Optional },
new[] { "Custom.Web.Controllers" }
);
}
in my controller I have the actionresult index as
public ActionResult Index(string Key)
{
return Redirect(workflow.RetrieveURL(Key));
}
"s/{key}"
, also changingid = UrlParameter.Optional
, tokey = UrlParameter.Optional
? – Andre CalilHome/Index
action. Do you have any other routing rule? – Andre Calil"s/{key}"
instead of"s/index/{key}"
– Andre Calil