if i have an route like /foo/bar/pewpew .. is it possible to get an instance of the controller which that route maps too?
if i have an route like /foo/bar/pewpew .. is it possible to get an
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To get the controller name, you can call create a fake
HttpContextBasethat returns your URL in itsRequest, then pass it toRouteTable.Routes.GetRouteDataand check theareaandcontrollervalues.To get the controller instance, pass a
RequestContextconsisting of thatHttpContextBaseandRouteDatatoControllerBuilder.Current.GetControllerFactory.CreateController.