I have Angular 2 and Webpack 2 starter which run on node by webpack-dev-server, and I what to run it from visual studio with web-api.
The problem is when angular2-webpack-starter run webpack-dev-server on port 3000. and IIS Express run on different port 5000.
This is very important to me because I want to use HMR and reload every time the files are changed.
So, How can be combine them together? run on the same port? or any other solution?
Configure IIS express on visual studioSelect the web application project and open properties -> select the web tab -> under server's select IIS express-> Specify the project URL. Now open the project folder and . vs folder (Hidden) -> Config -> applicationhost.
The reason - bad IIS config file. Try deleting the automatically-created IISExpress folder, which is usually located at %userprofile%/Documents , e.g. C:\Users\[you]\Documents\IISExpress . Don't worry, VS should create it again - correctly, this time - once you run your solution again. This worked for me.
I had the same dilemma and solved it just by using the proxy option in the webpack dev server config:
module.exports = {
devServer: {
contentBase: './dist', /* output folder */
proxy: {
'/api': { /* I had only to track calls to api, change path to one you need*/
target: 'http://localhost:15536/' /* specify your correct IIS port here */
}
}
},
/*other configurations here*/
}
After code is in place, just run the VS project and start WebPack Dev server alongside. Now all the calls from the app will be redirected to your ASP.NET server.
Let me know if any questions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With