I currently have a WCF service that operates on a database. I’d like to be able to use JavaScript (specifically AngularJS) to call the service methods and display them in a webpage.
I know this can be done using a separate ASP.NET client application that uses the service, but I’d like to have the JavaScript/HTML be a part of the WCF service project. Ideally, I’d like the user to see my webpage when running the service, rather than something like this: https://pieterderycke.files.wordpress.com/2011/01/service-page-in-internet-explorer.png, but I have no idea where to start.
Where must I put my JS/HTML files in the project and how do I reference them from the WCF service? Does something need to be done to expose the service to the JS/HTML files? Thanks in advance!
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
It’s actually rather simple, really just a matter of adding the files to your project. You just need to make sure the references within the JavaScript/HTML files all still point to the right spot. If you’re using AngularJS specifically, add that to the project first, then add your custom files.
Also, if you’re looking to show an HTML file when running the service in Visual Studio, have a look here: Displaying web page when running WCF service.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0