Hello I am new with ASP NET MVC
I have a web page with default routing
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}");routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); }
I have been working developing a URL shortener that creates 5 character strings in base 32 (A-Z 0-9). My idea is to have the default routing in ASP NET MVC and add a special case forwww.mypage.com/ASD12 //this is the random code generated by my application
How can I add this exception to my routing and always make URLs (mypage.test/code) land in a specific controller action
public class CodeController : Controller
{
public async Task<ActionResult> Index(string code)
{//do things here}
}
Thank you very much
#c-sharp #asp.net