Forums - C# Corner

Forum guidelines
vick b

vick b

  • 0
  • 6
  • 0

Web-API : Test Account setup in LIVE API

Jun 13 2018 12:53 PM
I have my backend WEB-API(api2) which is being called from the client app. I don't have any control over the client app and can't ask them to update any on their side.
I need to implement a way to access the "test" DB if the request is from the test account. We have separate servers for production and test DB's. I can identify the test account request but not sure the easy way (not necessarily best)to access the API afterwords. I'm thinking below 2 options
  • Redirect to "TEST API": I can easily set the "Test API" which will point to the test DB. So validate the "test account" and redirect to the 'test API' and send the response from it to the client. I'm thinking I can place this validation in "Application_BeginRequest" event in Global.asax. Any better ideas?
  • Other option is, based on the "request account" validation I need to change the connection-string to the DB. i.e each method in service and DB layer will have additional param to identify the test account.
Any thoughts and ideas on this situation? I prefer #1 for clean and better code management. If you agree with #1, can you please share a sample to implement it.

Answers (2)