kiransr kiransr - 9 days ago 8
ASP.NET (C#) Question

How to Host webAPI /HTML in IIS?

i have created a project in VS2015,My architecture goes like this,using ASP.NET empty website i have added few html,jquery,highcharts etc(not used any aspx page) and for same solution using webApi nuget packages i added controllers and added class libraries(Business layer,Data layer) to same project.so from html page using AGAX i am calling webapi(exsits in the same soloution) and controller methods will contact data layer to fetch data, i will get json and i will bind to HTML and i am using Token based authentication,everything is working perfectly.

Now the problem is how to HOST this solution in IIS,Initially what i did, first i published my solution API part and hosted in IIS(8081 port) and able to call webapi.
then i added my HTML(UI) part to IIS(8080 port) and able to browse the page , but while calling WEB API it leads to HTML CROSS problem, because WEB API is in Different Domain, so with few changes in WEBAPI i am able solve HTML CROSS problem but still few more challenges,

So is there any best solution for this, i am a mid level developer till now i haven't done any proper deployments.Can we host everything in one domian?
solution reference:http://www.codeproject.com/Articles/815916/Create-an-ASP-NET-Web-Forms-Application-using-Boot
enter image description here

Answer

Best way to avoid CORS problem is first publish your WEB API and in IIS add as new application for that application add your HTML website, since both are in same port in IIS, we can avoid CORS.

Comments