Webapi httpactionexecated context get ame controllerC#

Место общения программистов C#
Anonymous
Webapi httpactionexecated context get ame controller

Сообщение Anonymous »

Мне нужно получить контроллер, который запускает атрибут фильтра. < /p>
У меня есть следующий фильтр: < /p>

Код: Выделить всё

public override void OnException(HttpActionExecutedContext filterContext) {
if (filterContext == null) {
throw new ArgumentNullException("filterContext");
}

if (filterContext.Exception != null) {

// string controllerName = (string) filterContext.....??

// string actionName = (string) filterContext.....?

HttpResponseMessage msg = new HttpResponseMessage(HttpStatusCode.InternalServerError) {
Content = new StringContent("An unhandled exception was thrown by Customer Web API controller."),
ReasonPhrase = "An unhandled exception was thrown by Customer Web API controller."
};

filterContext.Response = msg;

}

}
< /code>
В традиционном MVC это было легко, делая: < /p>
string controllerName = (string) filterContext.RouteData.Values["controller"];
string actionName = (string) filterContext.RouteData.Values["action"];
Что я могу попробовать дальше?

Подробнее здесь: https://stackoverflow.com/questions/253 ... oller-name

Вернуться в «C#»