API problem after deploying

Asked

Viewed 47 times

0

My api is not working after deploy to the server, it is returning:

404 - File or directory not found.

The Resource you are Looking for Might have been Removed, had its name changed, or is temporarily unavailable.

Doing some tests I discovered the following, is making the call so and not right:

http://myServitor/api/Book

but if I do it right:

http://myServitor/api/api/Book

'Cause it’s right when I put api twice? I couldn’t do that in the code, apply api twice on the route.

  • You published it on IIS, right? By chance you created an application within the "Default web site"?

  • StatusCode 404 means address not found, your call is not hitting the API!

  • Already checked if route in production environment is equal to environment in development?

1 answer

1


What happened:

You created a app within your site (probably Default Web Site). With this is created a alias(In your case api) and to access your application you need to have the alias in the URL(this occurs independent of being a api or a web project), for example: http://localhost/alias/api/route

inserir a descrição da imagem aqui

How to solve:

You can publish your api on the "website" Default or create a "website" for the api, so you won’t have to go through alias, in the image example, I created a new website (right click on Websites>Add website)

inserir a descrição da imagem aqui

Possible "problem":

When creating websites, each one will be in a port, this way, if by chance you have an application web and a api published, each "site" will have a port

  • It makes sense, if this is the answer I leave my +1

  • The strange thing was that a little while ago it worked, anyway, I did what you suggested and created in "Sites" and it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.