c# - MVC and Web API Projects in the same Solution -


i created solution while ago contains web api 2 project (provides json data mobile devices) , class library (includes data access services).

the web api project uses ninject di , works fine.

now need add separate mvc project few web pages. api should accessible www.example.com/api/controller, while website should accessed through www.example.com/controller.

the problem each of these two, has different "register" method seemingly incompatible route collections. if set mvc project startup project, routes api not registered, , vice versa. if set "mutiple startup projects", run on different ports not cup of tea.

how can set mvc project startup project, while registering routes both of them?

one more thing. because web api project created sooner, ninject configuration has been written inside it. of course, of services class library project needed inside new mvc project. have move ninject configuration mvc project, or work because run on startup of web api project?

this 2 projects independent each other 2 different applications if in same solution.

to succeed try achieve have to:

1) deploy mvc project www.example.com (main virtual application).

2) deploy webapi project www.example.com/api (api folder virtual application). don't forget remove api webapi routes (other wise have use route www.example.com/api/api/controller).

doing can acces independently both projects in same url.

for ninject part, can register again services in mvc project. solution (which recommend) make class library project , register there services after reference class library in both projects.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -