c# - Unable to fetch returnurl in asp.net mvc Controller -
i have 2 controllers base , login.
base controller:
public actionresult start() { string action = request.querystring[wsfederationconstants.parameters.action]; }
login controller:
public actionresult login(string user,string password,string returnurl) { if (formsauthentication.authenticate(user, password)) { if (string.isnullorempty(returnurl) && request.urlreferrer != null) returnurl = server.urlencode(request.urlreferrer.pathandquery); return redirecttoaction("start","base", returnurl }); } return view(); }
after authentication done gets redirected start action in base controller expected. querystring doesnot fetch value. when hovered on querystring shows length value not uri.
how use url sent login controller in base controller , fetch parameters it?
you returning 302 client. docs.
returns http 302 response browser, causes browser make request specified action.
when doing client make request url created. in case youruri.org/base/start
. take @ network tab in browser (f12 in chrome).
what think want is:
return redirecttoaction ("start", "base", new { wsfederationconstants.parameters.action = returnurl });
assuming wsfederationconstants.parameters.action
constant. if wsfederationconstants.parameters.action
returns string foourl
action return following browser:
location:/base/start?foourl=url status code:302 found
another option pass value controller:
public class basecontroller: controller { public actionresult start(string myaction) { string localaction = myaction; //myaction automatically populated. } }
and in redirect:
return redirecttoaction ("start", "base", new { myaction = returnurl });
then basecontroller
automatically fetch parameter, , don't need fetch querystring.
Comments
Post a Comment