Having the following code:
return Request.CreateErrorResponse(
HttpStatusCode.BadRequest,
new ArgumentNullException("searchCriteria"));
I expect to be able to read ExceptionType back:
SearchCriteria searchCriteria = null;
HttpResponseMessage message = controller.Do(searchCriteria);
ObjectContent<HttpError> content = message.Content as ObjectContent<HttpError>;
HttpError error = (HttpError)content.Value;
string exceptionType = error.ExceptionType;
but the last line gives always `null`? Why is that?
Comments: Thank you, Yishai! Here's my code making the tests pass: ``` var config = new HttpConfiguration(); var request = new HttpRequestMessage(); request.SetRequestContext(new HttpRequestContext { IncludeErrorDetail = true }); request.SetConfiguration(config); T controller = (T)Activator.CreateInstance(typeof(T), args); controller.Request = request; return controller; ``` As you mentioned above, the key is that `controller.RequestContext` properties will be ignored if `request` has the same properties set beforehand.
return Request.CreateErrorResponse(
HttpStatusCode.BadRequest,
new ArgumentNullException("searchCriteria"));
I expect to be able to read ExceptionType back:
SearchCriteria searchCriteria = null;
HttpResponseMessage message = controller.Do(searchCriteria);
ObjectContent<HttpError> content = message.Content as ObjectContent<HttpError>;
HttpError error = (HttpError)content.Value;
string exceptionType = error.ExceptionType;
but the last line gives always `null`? Why is that?
Comments: Thank you, Yishai! Here's my code making the tests pass: ``` var config = new HttpConfiguration(); var request = new HttpRequestMessage(); request.SetRequestContext(new HttpRequestContext { IncludeErrorDetail = true }); request.SetConfiguration(config); T controller = (T)Activator.CreateInstance(typeof(T), args); controller.Request = request; return controller; ``` As you mentioned above, the key is that `controller.RequestContext` properties will be ignored if `request` has the same properties set beforehand.