I have a React website connected to Asp.net MVC webapi2. they are on two domain and it makes cross domain problems. How can I have them on the same domain?
IIS6 Asp.net 4.5
I have a React website connected to Asp.net MVC webapi2. they are on two domain and it makes cross domain problems. How can I have them on the same domain?
IIS6 Asp.net 4.5
I think you can create a site and a virtual directory. In the virtual directory you can deploy the apis.
So for example if your domain is www.yourdomain.com, this site points to the react application.
and you can create www.yourdomain.com/apis (Virtual folder) where you can deploy all the apis project.
Solution 1: Host Both in Different Folders in Same Server, and Use Same Domain.
Solution 2:
If its Cross-Origin Resource Sharing Problem. Then Enable CORS
in your WebApi
Project.
In API Controller:
[EnableCors(origins: "http://myreactclient.domain.com", headers: "*", methods: "*")]
public class TestController : ApiController
{
}