Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

ASP.Net 4.5 to ASP.Net core 2.0.1 migration issue of Authentication

$
0
0

Hello Developers, I am new to ASP.Net core 2.0.1, i studied the architecture of Authentication and identification in core framework,i facing some problems during migration, please help. In the Startup.cs file, I am using this piecce of code in ConfigureServices method

<div class="pre-action-link" id="premain926311">Hide   Copy Code</div>
app.use(async (context, next) =>
            {
// When the user is already authenticated, check if the session is still alive, if not, log him out.
//do something
await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
                    await context.Authentication.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme);
//OR 
 await next.Invoke();
}



Now in core, i dont know how to handle these 2 functions for logout

I get NULLREFERENCE Exception

<div class="pre-action-link" id="premain916634">Hide   Copy Code</div>
var projectId = context?.Session?.GetInt("Project_Id");

when page is refershed after a while.

Please help me to resolve these issue.

<div class="signature">Geetha</div>

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>