This topic is locked
[SOLVED]

 capture login url for later redirect to list page

6/30/2018 4:28:40 AM
ASPRunner.NET General questions
H
heilmanmd author

Emails are sent to users of the system with a link to the LIST page to be viewed
below is an example of such a link
http://catsnratstest.smcinternal.com/CATSNRATS_SUMMARY_BY_AREA/list?orderby=aAREA
when user clicks on the link the LOGIN screen appears
but the url gets changed by ASP runner to be the following
http://catsnratstest.smcinternal.com/login?return=true&;
and when they are logged in, it goes to the default landing page vs the page on the above original URL
after successful login the user is place on the default Landing Page and Not the page that is on the link that was emailed...
hum??
How / or is there a way to email a link and have the user login and have it go to the LIST page on the emailed hyperlink???
Any help appreciated.
Best

Mark

Big Timber, MT, USA

H
heilmanmd author 7/2/2018

ok... I figured it out....
set return=false and then the url for the list page as shown below
http://catsnratstest.smcinternal.com/login?return=false&CATSNRATS_SUMMARY_BY_AREA/list?orderby=aAREA
Whala
Might be good to add this to help doc somewhere since I gotta believe that sending an email with a system link to view a list page, etc.. is something commonly wanting to be done
Best

Mark

Big Timber, MT, USA

J
jetsguy 8/7/2018

not really working for me.

Do you have to process the "goto" parameter in the login event?

H
heilmanmd author 8/7/2018

here are my login page events for handling the passed goto part
Before Login event and After Successful login
between the two, you should be able to find all the code you need to use...
Best

Mark
Before Login Event
pageObject.setProxyValue("urlval",XSession.Session["urlval"].ToString() );
string url = HttpContext.Current.Request.Url.AbsoluteUri;
pageObject.setProxyValue("bpurl",url );
string gotopage = "";

int loc=0;
loc = url.IndexOf("goto=");

if ( loc > 0) {

gotopage = url.Substring(loc+5);
XSession.Session["gotopage"] = gotopage;

}
pageObject.setProxyValue("gotopage",gotopage);
And then here is the After successful login event
string sqlcmd="";

XVar rs;

XVar datars;

int hits=0;

string httpstr="";

string type_user="";

int num_sites = 0;

string user_site="";

int loc=0;
// global variable for sending email...

XSession.Session["sendpage"] = "";
string urlval= XSession.Session["urlval"].ToString();
string userid = Security.getUserName().ToString();

XSession.Session["userid"] = userid;
sqlcmd = "select count(distinct(site)) as num_sites from catsnrats.main_table ;";

rs=tDAL.CustomQuery(sqlcmd);

datars = CommonFunctions.db_fetch_array(rs) ;

if (datars ) {

num_sites= datars["NUM_SITES"]; }
sqlcmd="select count() as HITS from catsnrats.send_link where userid='" + userid + "';" ;
rs=tDAL.CustomQuery(sqlcmd);

datars = CommonFunctions.db_fetch_array(rs) ;

hits=0;

if (datars ) {

hits = datars["HITS"];

if (hits == 0){

sqlcmd = "insert into catsnrats.send_link(userid)values('" + userid + "');" ;

tDAL.CustomQuery(sqlcmd); }

else {

sqlcmd = " delete from catsnrats.send_link where userid ='" + userid + "'; commit work; " +

" insert into catsnrats.send_link(userid)values('" + userid + "');" ;

tDAL.CustomQuery(sqlcmd); }

}
// find out what type user is and how many sites access to
sqlcmd = "select count(
) as hits from catsnrats.adinfo where login_id='" + userid + "' ; ";
rs=tDAL.CustomQuery(sqlcmd);

datars = CommonFunctions.db_fetch_array(rs) ;

hits=0;

if (datars ) {

hits = datars["HITS"]; }
if (hits == 1 ) {

sqlcmd="select type_user,site from catsnrats.adinfo where login_id='" + userid + "' ; ";

rs=tDAL.CustomQuery(sqlcmd);

datars = CommonFunctions.db_fetch_array(rs) ;

if (datars ) {

type_user= datars["TYPE_USER"].ToString();

user_site= datars["SITE"].ToString();}

}
if ( hits == 0 ) {

httpstr = urlval + "/noaccess.asp" ;

MVCFunctions.HeaderRedirect(httpstr); }
XSession.Session["multisite"]="no";

XSession.Session["site"]="EBM";
string gotopage = "";

gotopage = XSession.Session["gotopage"].ToString();
if (gotopage.Length > 5 ) {

// redirect
loc=gotopage.IndexOf("site=");

if ( loc > 0 ) {

user_site=gotopage.Substring(loc+5,3);

XSession.Session["site"] = user_site; }
httpstr = urlval + "/" + gotopage ;

MVCFunctions.HeaderRedirect(httpstr); }
// now see if need to ask which site to go to...

if ( ( hits > 1 || type_user == "SPEC" ) && num_sites > 1 ) {

// COL EBM SWM are the choices...

XSession.Session["multisite"] = "yes";

sqlcmd = "select count(*) as hits from catsnrats.multiuser where userid='" + userid + "' ;";

rs=tDAL.CustomQuery(sqlcmd);

datars = CommonFunctions.db_fetch_array(rs) ;

if (datars ) {

hits = datars["HITS"];

if (hits==0){

sqlcmd="insert into catsnrats.multiuser(userid)values('" + userid + "') ;";

tDAL.CustomQuery(sqlcmd); }

else {

sqlcmd = "update catsnrats.multiuser set current_site='' where userid='" + userid + "' ;";

tDAL.CustomQuery(sqlcmd);

}
// redirect

httpstr = urlval + "/CATSNRATS_MULTIUSER/list" ;

MVCFunctions.HeaderRedirect(httpstr);
}

}

else {

XSession.Session["site"] = user_site ; }