Session set on asp.net MVC application is getting lost after redirection back from ADFS 3.0

91 views Asked by At

I am having MVC application which is integrated with ADFS .

Summary

I am setting a session before calling ADFS authentication. After the return of ADFS call,that session got lost which i set previously.

Detailed Description

Step 1 Calling application URL

https://hrcentral/mainmodule/expense/index

step 2 Above call redirect the request to WIF component which is a httphandler in my application hence url : https://hrcentral/federationMetaData/wif.axd ?ReturnUrl=https://hrcentral/mainmodule/expense/index

Web.config i have setting like below for redirection

 <authentication mode="Forms">
      <forms loginUrl="~/FederationMetadata/WIF.axd" name="smartForms" />
    </authentication>

Step 3: setting a session inside the WIF.axd httphandler reading returning url from query string

HttpContext.Current.Session["ReturnUrl"]="https://hrcentral/mainmodule/expense/index";

After setting session,it will redirect to ADFS

Step 4 ADFS authenticate and POST request https://hrcentral/federationMetaData/wif.axd will be send inside the same WIF handler.We have a condition to check whether request is POST or NOT. As this request is POST, previously stored session which contain the ReturnUrl and try to redirect back and land to our application.

Now the issue is the session which is set on step 3 (HttpContext.Current.Session["ReturnUrl"]=ReturnUrl) is not accessible after redirection from ADFS in wif.axd. In general any session ,any session which is set in our application is lost after the redirection from ADFS.

Authentication will happen after that it will redirect to https://hrcentral/mainmodule/expense/index

Setting session

0

There are 0 answers