he previous URL is passed as a Querystring variable.
For the login page to redirect to the previous page, the login form must pass the original querystring variables.
Set the forms action to:
action="<% If(Request.QueryString <> "")Then Response.Write(CStr(Request.ServerVariables("SCRIPT_NAME"))&"?"&Server.HTMLEncode(Request.QueryString)) Else Response.Write(CStr(Request.ServerVariables("SCRIPT_NAME"))) %>"