3

How do I go about hosting both my client and server in the same port? I have a Angular JS front end and Web API 2 service that I would like to be hosted on the same web server.

I have IIS installed locally and would like to use it, but I'm not sure how.

2
  • 1
    Not sure what the issue is, you would have a mvc + webapi project that would also have js and html for angularjs. Where does port come into picture. Commented Apr 22, 2014 at 13:43
  • CORS is giving me issues with the built in external authentication stuff for web api 2. I see no reason to have them on different hosts, So i was hoping i could put them on the same Commented Apr 22, 2014 at 14:24

1 Answer 1

1

You can not. You need to deal with different ports and CORS.

How would that work anyway? How IIS is going to know to redirect the call to frontend or backend? Without port it is not possible.

Only option is to have one project that is deployed to one port, but that is not a good fit for SPA in my opinion. In order to do that you need to return index.html from the WEB API project.

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

6 Comments

CORS is giving me issues with the built in external authentication stuff for web api 2. I see no reason to have them on different hosts, So i was hoping i could put them on the same
Why do you think it wouldn't be good to return index.html for the web api project?
just add a regular controller (not ApiController) and return a view that can be processed by razor.
Stride, Doesn't mvc require .cshtml files?
there are many ways to do that. One of them here buildingwebapps.blogspot.co.uk/2012/04/…
|

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.