We have a system that allows our parents (I work for a school district) to access district and class resources. It is a third-party product, which is the source of the problem. When a parent logs in, they are actually logging in to a site that I have built. I have to do some checks on their account to see whether they are authorized to pass on to the third-party site. If they are authorized, I simply do an automated form submit with the appropriate login information for the parent.
The problem I’m having is that our vendor doesn’t regularly load new data. So, if a student is newly registered at one of our schools, the parent can login and authorize on my side but when I send them to the third-party site, they get an error message indicating no students. I have no way of querying the vendor to see if they will allow the parent in.
What I need to do is run the forms submit to the third party in a “testing” mode that will capture the resulting page in a buffer so I can test the buffer for the error message. If the error message exists, I’ll keep them on my side and present them with basic resources. Otherwise, if the error message doesn’t exist, I need to do the actual form submit and allow the browser to re-direct. Possibly an AJAX solution? The following is the existing code:
ASPX page (yes, I have the appropriate headers, etc., this is the relevant code):
<form method="post" name="loginform" action="http://[destination page]" target="_top">
<input type="hidden" name="username" value="<% =SessionHandler.UserEmail %>" />
<input type="hidden" name="password" value="<% =SessionHandler.UserPassword %>" />
<%--<input type="submit" name="Submit" value="Login" />--%>
</form>
Javascript (that executes the form submit):
function parentFormSubmit() {
document.loginform.submit();
}
VB Codebehind:
Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete
Session.Abandon()
FormsAuthentication.SignOut()
Page.ClientScript.RegisterStartupScript(Me.[GetType](), "alert", "parentFormSubmit();", True)
End Sub
If I understood correctly the way you can accomplish this is by doing a manual HTTPPost by either using a Socket or the
WebRequestclass.Using the WebRequest Class
Sockets
I would use the WebRequest class because it is easier and faster and you could find tons of samples online.
Good luck!