Where is the proper place to put this authentication logic?
===

We have an old classic asp app that is used to manage and launch our other web applications.

The way it launches apps is as follows:

    <form name="frmMain" action="http://xxxx/mvc3app/Index" target=_self method=post>
    <script language="javascript">
    frmMain.submit();
    </script>

User login and password is passed through as part of the request. 

To Authenticate the user in the ASP.NET app I call the following AuthenticateUser function:

    public bool AuthenticateUser()
    {

     var userName = Context.Request["txtName"];
     var password = Context.Request["txtPassword"];   
        
        if (Membership.ValidateUser(userName, password))
        {
           FormsAuthentication.SetAuthCookie(userName, true);              
        }
    }

I assumed that the correct place to call AuthenticateUser would be in the `Session_Start()` method in global.asax but it doesn't seem that this method is called when submitting "frmMain". It seems to work intermittently - if I close IE completely, try again and then enter the URL manually. 

    void Session_Start(object sender, EventArgs e)
    {
       Log("In Session Start");
       AthenticateUser();
    }


***Where would be the correct place to in my ASP.NET app to authenticate users?***

Here is a screeny from dev tools of the forms auth failing - Session_Start() isn't called.

![enter image description here][1]


  [1]: http://i.stack.imgur.com/LJusJ.png