asp.net mvc - MVC 5 does a controller exist -


i coding mvc 5 internet application , wish know if possible check if controller exists have name of controller?

i have application_error function gets name of controller when error occurs, , wish redirect index method of controller. problem user can enter in controller name not exist, , redirecting controller results in endless loop.

thanks in advance.

var temprequestcontext = new requestcontext(request.requestcontext.httpcontext,                                              new routedata()); temprequestcontext.routedata.datatokens["area"] = ""; temprequestcontext.routedata.datatokens["namespaces"] = "yourcompany.controllers"; var controller = controllerbuilder.current.getcontrollerfactory()             .createcontroller(temprequestcontext, "controllername");  if(controller != null) {    //todo: redirect } 

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -