Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7707443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:21:41+00:00 2026-06-01T00:21:41+00:00

My scenario is this: A client application executes a HTTP POST against an endpoint

  • 0

My scenario is this:

  1. A client application executes a HTTP POST against an endpoint exposed by OpenRasta.
  2. The body of the request contains an error that causes a problem in the codec – which is a custom implementation of OpenRasta.Codecs.IMediaTypeReader. This converts a JSON payload to the POCO expected by the handler.
  3. The codec throws an exception that describes the error in a useful way. For example: Newtonsoft.Json.JsonReaderException: After parsing a value an unexpected character was encountered: ". Line 4, position 5.
  4. The client application receives a HTTP 405 – MethodNotAllowed. The client doesn’t see any of the exception details.

If the codec is modified to catch a JsonReaderException and return Missing.Value, similar to the Implementing a codec wiki, then the client receives a HTTP 500 – Internal Server Error. The body of the response also describes the following exception:

System.InvalidOperationException: The operation is not ready for invocation.
   at OpenRasta.OperationModel.MethodBased.MethodBasedOperation.Invoke()
   at OpenRasta.OperationModel.Interceptors.OperationWithInterceptors.<Invoke>b__0()
   at OpenRasta.OperationModel.Interceptors.OperationWithInterceptors.Invoke()
   at OpenRasta.OperationModel.OperationExecutor.Execute(IEnumerable`1 operations)
   at OpenRasta.Pipeline.Contributors.OperationInvokerContributor.ExecuteOperations(ICommunicationContext context)
   at OpenRasta.Pipeline.PipelineRunner.ExecuteContributor(ICommunicationContext context, ContributorCall call)

How should I modify my application so that:

  • The client receives a HTTP 400 Bad Request.
  • The client receives a string containing the details of the exception encountered in the codec.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:21:43+00:00Added an answer on June 1, 2026 at 12:21 am

    Having found this thread on Google Groups which contains all the answers, my current implementation looks something like this.

    Within my implementation of IConfigurationSource:

    using (OpenRastaConfiguration.Manual)
    {
        ResourceSpace.Uses.PipelineContributor<ErrorCheckingContributor>(); 
    
        // Other configuration here
    }
    

    Then ErrorCheckingContributor looks something like this:

    public class ErrorCheckingContributor : IPipelineContributor
    {
        public void Initialize(IPipeline pipelineRunner)
        {
            pipelineRunner
                .Notify(CheckRequestDecoding)
                .After<KnownStages.IOperationResultInvocation>()
                .And.Before<KnownStages.ICodecResponseSelection>(); 
        }
    
        private static PipelineContinuation CheckRequestDecoding(ICommunicationContext context)
        {
            if (context.ServerErrors.Count == 0)
            {
                return PipelineContinuation.Continue;
            }
    
            var first = context.ServerErrors[0];
            if (first.Exception is Newtonsoft.Json.JsonReaderException)
            {
                context.Response.Entity.ContentType = MediaType.TextPlain;
                context.Response.Entity.ContentLength = first.Exception.Message.Length;
                using (var sw = new StreamWriter(context.Response.Entity.Stream))
                {
                    sw.Write(first.Exception.Message);
                }
            }
    
            return PipelineContinuation.Continue;
        } 
    }
    

    There’s some things to be aware of with the above:

    • If a handler were to throw a JsonReaderException, it would also be processed here.
    • It doesn’t check what media types the client accepts. This is different from exceptions thrown by Handlers that do go through codec selection.
    • Tried setting context.OperationResult to context.ServerErrors – but it doesn’t go through the codec.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we have this scenario: A server which contains needed data and client component which
In LiveId Web Auth scenario, when client application receive clearcookie request, it is responsible
Here is my scenario... Users client application makes a request to a web service
I have a desktop client application build under .net 4.0 and WPF. In this
It seems that i have this weird behavior in my Web Client My application
Consider this scenario: I've an XML file called person.xml with the following data in
Consider this scenario. I have my own website, that I use as my identifier,
Consider this scenario. I have an object, lets call it.... Foo. Foo raises a
This scenario comes up often, now that I use LinkToSql and the classes it
Is this scenario even possible? class Base { int someBaseMemer; }; template<class T> class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.