2

In my MVC4 web app, I need to support multiple APIs. I looked around and apparently in Web API, Controllers with same name in different name spaces is not supported.

What are my options?

Ex: I want to be able to provide to my API consumers links like,

http://domainurl/api/api1/Students...
http://domainurl/api/api2/Students...

A Student Resource in api1 can be totally different from the one in api2. In such cases what is the best approach? I do not want to make it a single api and handle it through url parameters.

1
  • Ok. Looks like this is possible through Areas, as per THIS POST but not sure how much tweaking is involved in my case. Any simpler solutions, please suggest. Commented Nov 8, 2012 at 21:36

1 Answer 1

3

Maybe it might be better to seperate the 2 different APIs in to two different projects and have them worry about their own Apis.

  • MyApi.V1.csproj
  • MyApi.V2.csproj

Then have IIS point to the seperate versions using a virtual application

I think this is more manageable than smashing them into the same project file. Plus this will help each project out with reflection if you decide to use any resolvers.

Sign up to request clarification or add additional context in comments.

2 Comments

I believe that you are missing his point. It's not two version of the same API (for which your solution would make sense), but two different api that might share some (if not all) controller names. The MVC routes actually support that scenario by specifying the namespace in the route.
Oh. I would still have just branched/forked the next version and left V1's controller signatures unchanged except for bug fixes etc... V2 would be the continuation. (That's just me though...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.