A bad captive portal status code may be caused by a known issue with certain Cisco controller firmware versions. The issue can be viewed here: https://quickview.cloudapps.cisco.com/quickview/bug/CSCvj17640
The issue is caused by the custom web auth page not correctly setting the from's POST URL. It can be resolved by a simple change to the form.
The web form needs to be modified to ensure that the HTML body tag fires the loadAction function, as follows:
<body onload="loadAction();>
This function will set the form's POST URL to the switch_url query string parameter, which will allow login to proceed correctly.