1

I have a web api returning json and I have Mvc website consuming that web api. I want to make api calls on the clientside using Jquery, not in the mvc controllers on the serverside. Therefore I don't want to publish them as 2 different application with 2 different domains as it will cause cross site scripting.

ex. mywebsite.com for mvc webapp

mywebsite.com/api for web api

Ok I figured out how to run them under same domain as explained nicely here But I believe all of these solutions requires deploying the webservice and web api separatly even they run under the same domain? I want to publish only mvc webapp and api should be published together with it. is it possible?

for example something like "nopcommerce" project is doing with Nop.Web and Nop.Admin? When publishin Nop.web also includes nop.admin and nop.admin is reacheable with the url like nopcommerce.com/admin

Community
  • 1
  • 1
Emil
  • 6,411
  • 7
  • 62
  • 112
  • Well, for one thing, your MVC project can also include Web Api, so you could get away with just one project, if you wanted. Then this is trivial. – Chris Pratt Dec 18 '15 at 15:29
  • But is it a good architecture if I also want to give my web api externally like a web service? – Emil Dec 18 '15 at 15:31
  • Honestly, it doesn't matter. I'd say if your plans are to keep it together with your MVC site, then just merge them. You can always break it out later into a separate project, if the need arises. – Chris Pratt Dec 18 '15 at 15:33
  • you mean by merging simply creating an api controller in the MVC application or is there some better way? – Emil Dec 18 '15 at 15:47
  • 2
    Yes, you can just add the Web Api nuget and then create api controllers. How you choose to organize your project is up to you. You could utilize areas or whatever makes sense. – Chris Pratt Dec 18 '15 at 16:26
  • Is this a general question about MVC / Web API or specific to nopCommerce? Answers would be different. – Marco Regueira Dec 20 '15 at 22:53
  • It is a general question. Nopcommerce was just a sample. I thought it could be similar implementation. – Emil Dec 21 '15 at 10:40

0 Answers0