I have an ASP.NET 4.0 web application which uses a third-party API for external data, the way the API works it requires a username/password upon initialization by prompting a GUI represented as a Winform window, if I put the correct credentials the window closes, the initialization finishes, then data start to come through.
You probably get the twist here, when my ASP.NET work processor starts it starts the API’s initialization, therefore I have to literally be on the server where the web app is located to enter username and password for the API to complete the initialization, due to this limitation it will be problematic for me to deploy the web app to production where users need to enter their own API’s credentials (yes users also have their own credential for the API).
Is there a solution? I was thinking of writing another application that would wait for the winform login prompt to enter the credential based on the passed username/password from the web application. Is this even possible? If not, is there anyway around it?
If it is indeed a WinForms form used for logon, you can access it via the OpenForms collection. From there, you can locate the appropriate textboxes and buttons. If the API is blocking, you may need to do this from another thread. Don’t forget to use Invoke to run your function in the correct thread once you’ve found the form.