texas697
texas697

Reputation: 6397

How to name api routing on a webhost sub folder

I have always thought the api controllers where not found by physical paths. The reason I ask is I have a website example.com I created a folder example.com/testing and uploaded my project to there. When I ran it I got errors saying that none of the apiControllers could be found. So I changed /api/apiCustomers to /testing/api/apiCustomers. It then worked, well not the actual posting of any new records. It did locate and retrieve all the records from the database though. But it doesn't seem like that is what I would actually need to do? I have a domain with WinHost and the default publish folder is example.com/myApp AM I looking at this the wrong way?

Upvotes: 0

Views: 22

Answers (1)

Stephen Reindl
Stephen Reindl

Reputation: 5819

To handle request where you do not know the root path, you can use (as in ASP.NET) the ~-character like this:

~/api/apiCustomers 

~ will then be replaced by the root (i.e. /api/apiCustomers for prod and /testing/api/apiCustomers for your test environment)

Upvotes: 2

Related Questions