Overriding POST - Contributor to execute twice

39 views
Skip to first unread message

gobanyoshi

unread,
Jan 6, 2012, 3:50:37 PM1/6/12
to OpenRasta
I'm new to OpenRasta and seem to be having issues with the
HttpMethodOverriderContributor. I've followed the instructions for
Overiding POST listed here:

http://trac.caffeine-it.com/openrasta/wiki/Doc/BuildingSites/DownLevel

I'm using Fiddler to send request and test. My Get and Post functions
are working fine. However, when I send this:

POST http://localhost:57783/home HTTP/1.1
X-HTTP-Method-Override: PUT
Host: localhost:57783

I get the following error:

'Overriding the http method is not supported on method PUT'

'The X-HTTP-Method-Override http header can only be added to requests
that are sent as a POST.
Http methods are case-sensitive, make sure the method is in all upper-
case.'


When I put a break point in OverrideHttpVerb (from
HttpMethodOverriderContributor) I notice that it executes twice. The
first time context.Request.HttpMethod is set to "POST" and everything
executes fine. Then it overrides context.Request.HttpMethod with the X-
HTTP-Method-Override value. So the second time
context.Request.HttpMethod is now equal to "PUT" and it fails the
"POST" test and returns the error.

Is there something I'm doing wrong that is causing the Contributor to
execute twice.

I am using OpenRasta Stable 2.0. My config class is as follows:

public class Configuration : IConfigurationSource
{
public void Configure()
{
using (OpenRastaConfiguration.Manual)
{
//Override support for GET and POST only clients

ResourceSpace.Uses.PipelineContributor<HttpMethodOverriderContributor>();

//Home Resource and Handler
ResourceSpace.Has.ResourcesOfType<Home>()
.AtUri("/home")
.HandledBy<HomeHandler>()
.RenderedByAspx("~/Views/HomeView.aspx");
}
}
}

Greg Sochanik

unread,
Jan 7, 2012, 4:03:02 AM1/7/12
to open...@googlegroups.com
I'm not 100% but I've got a feeling that contributor is already hooked into the pipeline by default, so if it's being fired twice, then it's because you're registering it again in the configuration.Configure() method.

Try it without this:

ResourceSpace.Uses.PipelineContributor<HttpMethodOverriderContributor>();

Cheers,
Greg

gobanyoshi

unread,
Jan 7, 2012, 10:42:03 AM1/7/12
to OpenRasta
Greg, thanks so much! I don't know why I didn't try that, but it
worked perfectly. So I think your assumption is correct, it must be
hooked in by default now.

Cheers,
Jon
Reply all
Reply to author
Forward
0 new messages