Sidharth
Sidharth

Reputation: 1251

IIS URL Rewrite - Convert POST to GET

In my application there is a client and a WCf REST service. For invoking some wcf service the client is doing an http POST even though the service is a GET.

i do not want to do any changes in the client or the service.

So is there a way where i can convert this POST request to GET and add the data coming in as the POST to the URL and invoke the REST service.

Thanks in advance.

Upvotes: 1

Views: 5955

Answers (1)

LazyOne
LazyOne

Reputation: 165403

You can use URL Rewrite to issue 3xx Redirect which will use GET method, but you will loose all POST data.

The only safe way known to me is to rewrite POST request to some another custom page, where you:

  • collect all POST data/variables;
  • convert them into GET variables (assemble proper GET request);
  • issue 301 (or 302) Redirect to the proper URL (it will have all POST data sent as GET variables).

Such rewrite to custom page should be easy -- you need to check what method is used (POST or GET) and only invoke it on POST. The rest will be handled in that post-to-get script.

The reason for all of this complexity is the difference in how POST and GET requests work: with GET all data is sent as part of URL while POST uses request body to transfer variable's data.

Upvotes: 1

Related Questions