4

I've built a service using OpenRasta. I'm validating resources in a operation interceptor. If validation fails a BadRequest is returned with an ErrorResource as JSON. The ErrorResource contains a list of error messages. On my local machine the ErrorResource is returned correctly in JSON format. The response content type is application/json. On our test environment the service responds with a BadRequest but the content type is text/html. The list of error messages is not returned. Instead the response contains the message "Bad Request". Any ideas why this is happening?

Here is a simplified version of the interceptor:

public override bool BeforeExecute(IOperation operation)
{
    var errorResource = new ErrorResource();

    errorResource.AddErrorMessage("Error!");

    _communicationContext.OperationResult = new OperationResult.BadRequest() { ResponseResource = errorResource };

    return false;
}

Here is a simplified version of the configuration:

using (OpenRastaConfiguration.Manual)
{
    ResourceSpace.Has
        .ResourcesOfType<ErrorResource>()
        .WithoutUri
        .AsJsonDataContract();

    ResourceSpace.Uses.CustomDependency<IOperationInterceptor, InputValidationInterceptor>(DependencyLifetime.Transient);
}
  • could you post your configuration snippet that shows how the ErrorResource is configured? Also post your interceptor? – taylonr Jun 23 '11 at 15:16
  • I've added the relevant code above. Like I said it works on my machine :-) But not on our test environment :-( – JuniorDeveloper Jun 23 '11 at 15:36

1 Answers1

4

Disable error pages in IIS. There's some info in an email on the mailing list. See http://groups.google.com/group/openrasta/browse_thread/thread/50ac9048d8e4a77e/4977aab1334a3e60?#4977aab1334a3e60

SerialSeb
  • 6,701
  • 24
  • 28