Fake URI

Topics: Web Api
Dec 4, 2011 at 3:03 AM

Hi. I tried to find a solution for my problem in the forum but didn't found a good one.

Let's suppose I have two services with one operation each.

http://localhost:2000/contacts

http://localhost:2000/addresses

But I have some organisations, so the services would be

http://localhost:2000/{orgid}/contacts

http://localhost:2000/{orgid}/addresses

I can do it putting the {orgid} parameter in each operation but I would like to do it in a more generic way. I tried to use RequestHandlers, OperationHandlers and HttpOperationSelector but it didn't work. Basically they are not even called because the uri with a {orgid} on it doesn't really exists.

I also tried to open a host with a base address like http://localhost:2000/ but I had to set any service to it and apparently the request does not accept changing it on the middle.

Can anybody help?

Thank you  

Coordinator
Dec 4, 2011 at 8:41 PM
Edited Dec 5, 2011 at 4:48 PM
With the current bits you can only have one service per static base address. This means that you will need to have a single service with uritemplates on ops that support the Uri space you care about.

This situation will get better once we add full support for ASP.net routes.
Dec 5, 2011 at 1:48 PM

Since I'm using  a standalone host, will I be able to use ASP.NET routes?

What I miss here is an event that allows me to change some request details before any handling by the API.

While I was using IIS hosting, I had the begin request event, despite I think I could not change the request uri there.

 

Thanks Dan.

Coordinator
Dec 6, 2011 at 6:32 AM

Right, you can modify the request message in the Web API pipeline, but the pipeline is tied to a single service right now.

When web hosted you can try modifying the request using an ASP.NET module. URL rewriting might be a potential solution.

More details on our routing and self-host story will be coming soon. In general though we want to keep our web-hosted and self-hosted experiences as consistent as possible.

Daniel Roth

From: cassiot [email removed]
Sent: Monday, December 05, 2011 6:49 AM
To: Daniel Roth
Subject: Re: Fake URI [wcf:281729]

From: cassiot

Since I'm using a standalone host, will I be able to use ASP.NET routes?

What I miss here is an event that allows me to change some request details before any handling by the API.

While I was using IIS hosting, I had the begin request event, despite I think I could not change the request uri there.

Thanks Dan.