Using Async, Await, Plus a Slight Delay

Today’s problem dealt with how we view our invoices online.  We use an app on the iSeries that creates a PDF and delivers it to a set destination.  That destination, in our case is a regular windows server, the files landing in a small site:   pdf.mycompany.com.

My initial approach was simple, use the PHP API I have sitting on the iSeries to make a call to the program – passing it the parameters for that specific invoice, await response (which gave me the new created filename) and then redirect to that URL.  The method looks something like this:

[HttpGet]
public async Task<ActionResult> GetInvoiceAsync(int invoice)
{
    GetInvoice getInvoice = new GetInvoice();
    var client = new HttpClient();

    string fileName = await getInvoice.LoadPDF(invoice);

    string url = "http://pdf.mycompany.com/";
    url += fileName + ".pdf";

    return Redirect(url);
}

 

This worked great… 90% of the time, but the other 10% of the time, I clicked too quickly on an invoice and got forwarded to a 404.…

Securing AS400 / iSeries (Comodo Free SSL)

Enabling SSL certificates with Comodo’s Free 90 Day trial SSL Certificate.  This process enables you to secure both web services, login, and SSL across all other servers/services on the AS400 / iSeries.

Note:  If you are replacing/renewing your cert and something goes wrong, do not be afraid to delete your certificate store (if this is your only cert) and start fresh with this tutorial.  I’ve done it twice, now, as the key in store had trouble matching the new cert, etc…  I deleted certificate store, followed my own tutorial and was up and going in minutes.