I inherited a rather undocumented Visual Studio API project with many subprojects, one of which is called API
, and I assume what I am looking at is ASP.net.
I have been working with APIs built with different different technologies and frameworks (perl, cgi, python, flask, just to name a few), but I am new ASP.net. After days of research I got the API running in Visual Studio (VS), and it also talks with the UI.
Since I have two Startup Projects in VS, two browser windows open-up when hitting Start in VS, the UI and the API. The UI does what it is suppose to do, but the browser with the API shows an HTTP 404 error like this
This means that I might have various endpoints /foo
and /bar
defined, but not /
. How do I do that? Ideally, it should give back a json with the name and the current version of the API-(sub)project.
I am missing the correct ASP.net search terms in order to solve the issue myself. I am even struggling to implement the workaround to serve a plain HTML file at /
. Where in the project tree comes the index.html
? I tried the root folder, as well as a folder called public
, but both does not work, I keep receiving the 404 error.
Your help is very much appreciated!
You have two options here, for automatically documenting your endpoints.
If you go for the option 1 then you will probably need to play around with with project templates and choose one that fits. Then you should copy all of your existing code into the new project template.
Swagger seems to be more popular now so you should try that, especially if you are working on a modern code-base. You can add XML comments to the controller endpoints and they will appear on your swagger page, http:/localhost/swagger/ui/index
. You will need to install the nuget package and follow the tutorial.
Assume you created a file index.html
located in the root directory, in order to get that shown as (sub)project start page, right-click on the project in the Solution Explorer , choose Properties . A new view will pop-up where you define the Web > Start Action to point to a Specific Page (rather than Current Page ) where you enter index.html
. Hit CTRL+S
to save, and start the project.
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.