简体   繁体   中英

How can I deploy an ASP.NET Web API with React frontend to IIS?

I am trying to deploy my react app with a .NET Web API backend to IIS. In order to get the react app to show up I add the "homepage" property to my package.json for example "homepage": "/testapp/". The client app works and routes properly but any requests to the api just return the react app again instead of json data. When I launch the app locally in Visual Studio using IIS Express everything works fine. When I deploy the app all of api my routes for example /testapp/api/logs no longer return data (/api/logs returns 404). Does anyone have any insight on how to handle client side vs back end routing when deploying to IIS?

It was an issue with the connection to the data string. I added a test controller and found that the api was returning static data successfully. When it tried to hit the database it would return the index.html as an exception. I changed my site's authentication in IIS from anonymous to windows authentication and now my API returns data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM