How to redirect to login page when access token and refresh token expires










0















Hi Following from my previous question I need to rediect the user to the login page if the access and refresh token is expired. The problem is that I don't know how to get the address of the login page without hard coding it.



 public async Task<ActionResult> Shouts()

var authServerInfo = await this.GetAuthenticationServerInfo();
var accessToken = await HttpContext.GetTokenAsync("access_token");

var tokenClient = new TokenClient(authServerInfo.TokenEndpoint, "AuthTest_Code", "secret");
using (var client = new HttpClient())

client.SetBearerToken(accessToken);
var content = await client.GetStringAsync("http://localhost:5002/api/Values/Get");
var data = JsonConvert.DeserializeObject<List<String>>(content);
return View("Shouts", data);











share|improve this question


























    0















    Hi Following from my previous question I need to rediect the user to the login page if the access and refresh token is expired. The problem is that I don't know how to get the address of the login page without hard coding it.



     public async Task<ActionResult> Shouts()

    var authServerInfo = await this.GetAuthenticationServerInfo();
    var accessToken = await HttpContext.GetTokenAsync("access_token");

    var tokenClient = new TokenClient(authServerInfo.TokenEndpoint, "AuthTest_Code", "secret");
    using (var client = new HttpClient())

    client.SetBearerToken(accessToken);
    var content = await client.GetStringAsync("http://localhost:5002/api/Values/Get");
    var data = JsonConvert.DeserializeObject<List<String>>(content);
    return View("Shouts", data);











    share|improve this question
























      0












      0








      0








      Hi Following from my previous question I need to rediect the user to the login page if the access and refresh token is expired. The problem is that I don't know how to get the address of the login page without hard coding it.



       public async Task<ActionResult> Shouts()

      var authServerInfo = await this.GetAuthenticationServerInfo();
      var accessToken = await HttpContext.GetTokenAsync("access_token");

      var tokenClient = new TokenClient(authServerInfo.TokenEndpoint, "AuthTest_Code", "secret");
      using (var client = new HttpClient())

      client.SetBearerToken(accessToken);
      var content = await client.GetStringAsync("http://localhost:5002/api/Values/Get");
      var data = JsonConvert.DeserializeObject<List<String>>(content);
      return View("Shouts", data);











      share|improve this question














      Hi Following from my previous question I need to rediect the user to the login page if the access and refresh token is expired. The problem is that I don't know how to get the address of the login page without hard coding it.



       public async Task<ActionResult> Shouts()

      var authServerInfo = await this.GetAuthenticationServerInfo();
      var accessToken = await HttpContext.GetTokenAsync("access_token");

      var tokenClient = new TokenClient(authServerInfo.TokenEndpoint, "AuthTest_Code", "secret");
      using (var client = new HttpClient())

      client.SetBearerToken(accessToken);
      var content = await client.GetStringAsync("http://localhost:5002/api/Values/Get");
      var data = JsonConvert.DeserializeObject<List<String>>(content);
      return View("Shouts", data);








      asp.net-core-2.0 identityserver4






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 9:11









      DavidDavid

      3,127123357




      3,127123357






















          2 Answers
          2






          active

          oldest

          votes


















          0














          You could add it as a setting in your appsettings.json file.



          I have several ADFS settings stored in this file. An example of how it could look like is this:




          "PublicUrl": "BASE_URL_HERE",
          "ConnectionStrings":
          //Connection strings here
          ,
          "ApplicationInsights":
          "InstrumentationKey": "APPINSIGHTS_INSTRUMENTATIONKEY_HERE"
          ,
          "Logging":
          "IncludeScopes": false,
          "LogLevel":
          "Default": "Error",
          "Microsoft": "Warning",
          "Roxit": "Warning"

          ,
          "Authentication":
          "AdfsBaseUrl": "ADFS_BASEURL_HERE",
          "AdfsLogout": "ADFS_LOGOUT_URL_HERE",
          "AdfsLogin": "ADFS_LOGIN_URL_HERE",




          As you can see I have a logout and login url. How to retrieve these configuration settings in your code you can read here: How to read AppSettings values from Config.json in ASP.NET Core






          share|improve this answer

























          • what would that setting be?

            – David
            Nov 14 '18 at 9:27











          • See the updated answer.

            – JKL
            Nov 14 '18 at 9:44












          • That won't help I recently tried to redirect to rhe login page usingRedirect("localhost:5000/account/login); but I needed to build my return url in the query string and that failed.

            – David
            Nov 14 '18 at 10:07












          • Can't you do something like return Redirect("localhost:5000/account/login");?

            – JKL
            Nov 14 '18 at 10:48











          • the redirect url looks like this localhost:5000/account/… I don't know how to build this from scratch

            – David
            Nov 14 '18 at 11:38


















          0














          In ASP.Net you'd typically let the cookie authentication middleware handle this - i.e. if you do a HttpContext.SignOut("...my cookie scheme...") or the cookie expires then the next request to a secured action will automatically redirect to the login URL associated with that scheme.



          It's also worth noting that the intention of OpenID Connect is that you'd align the session/auth cookie lifetime of your client web application to that of the IDP session and NOT to the lifetime of an access_token which would typically be much shorter (and renewed silently using a refresh token in a server-side application like this).



          Check out the session management optional spec here:



          https://openid.net/specs/openid-connect-session-1_0.html



          You are of course free to define your own rules for how often an end user of your client must authenticate. You can use the max_age or prompt=login authorize endpoint arguments to force interactive authentication and then check the auth_time claim in the client app to verify that the user was indeed recently authenticated.



          To pass additional parameters using the normal .Net Core 1.1 middleware it might looks like the following (2.x may be slightly different):



          //Initialising OpenIdConnectEvents...
          OnRedirectToIdentityProvider = context =>
          //context.Properties is of type AuthenticationProperties which can be passed via the Challenge() method.
          if(context.Properties.Items.ContainsKey("prompt"))
          context.ProtocolMessage.Prompt = context.Properties.Items["prompt"];






          share|improve this answer

























          • Just to be clear the way I should handle this is to logoff then redirect to my action. This should redirect me to the login page. THe only problem with this is the logoff is not seamless. I need to go to my Auth server logoff page first.

            – David
            Nov 14 '18 at 14:18






          • 1





            @David only if you want to sign out of your auth server too but it doesn't make sense to do that just because a token it issued has expired.

            – mackie
            Nov 14 '18 at 15:09











          • If you can write a small code snippet in asp.net core on how to pass "prompt=login" I'll give you the tick.

            – David
            Nov 15 '18 at 6:55












          • @David See my edit

            – mackie
            Nov 15 '18 at 9:36











          • I tried this.I used await HttpContext.ChallengeAsync("oidc", prop); tp redirect to the Auth server but it just skips I cannot get the auth server login page to display

            – David
            Nov 20 '18 at 18:46











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296529%2fhow-to-redirect-to-login-page-when-access-token-and-refresh-token-expires%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You could add it as a setting in your appsettings.json file.



          I have several ADFS settings stored in this file. An example of how it could look like is this:




          "PublicUrl": "BASE_URL_HERE",
          "ConnectionStrings":
          //Connection strings here
          ,
          "ApplicationInsights":
          "InstrumentationKey": "APPINSIGHTS_INSTRUMENTATIONKEY_HERE"
          ,
          "Logging":
          "IncludeScopes": false,
          "LogLevel":
          "Default": "Error",
          "Microsoft": "Warning",
          "Roxit": "Warning"

          ,
          "Authentication":
          "AdfsBaseUrl": "ADFS_BASEURL_HERE",
          "AdfsLogout": "ADFS_LOGOUT_URL_HERE",
          "AdfsLogin": "ADFS_LOGIN_URL_HERE",




          As you can see I have a logout and login url. How to retrieve these configuration settings in your code you can read here: How to read AppSettings values from Config.json in ASP.NET Core






          share|improve this answer

























          • what would that setting be?

            – David
            Nov 14 '18 at 9:27











          • See the updated answer.

            – JKL
            Nov 14 '18 at 9:44












          • That won't help I recently tried to redirect to rhe login page usingRedirect("localhost:5000/account/login); but I needed to build my return url in the query string and that failed.

            – David
            Nov 14 '18 at 10:07












          • Can't you do something like return Redirect("localhost:5000/account/login");?

            – JKL
            Nov 14 '18 at 10:48











          • the redirect url looks like this localhost:5000/account/… I don't know how to build this from scratch

            – David
            Nov 14 '18 at 11:38















          0














          You could add it as a setting in your appsettings.json file.



          I have several ADFS settings stored in this file. An example of how it could look like is this:




          "PublicUrl": "BASE_URL_HERE",
          "ConnectionStrings":
          //Connection strings here
          ,
          "ApplicationInsights":
          "InstrumentationKey": "APPINSIGHTS_INSTRUMENTATIONKEY_HERE"
          ,
          "Logging":
          "IncludeScopes": false,
          "LogLevel":
          "Default": "Error",
          "Microsoft": "Warning",
          "Roxit": "Warning"

          ,
          "Authentication":
          "AdfsBaseUrl": "ADFS_BASEURL_HERE",
          "AdfsLogout": "ADFS_LOGOUT_URL_HERE",
          "AdfsLogin": "ADFS_LOGIN_URL_HERE",




          As you can see I have a logout and login url. How to retrieve these configuration settings in your code you can read here: How to read AppSettings values from Config.json in ASP.NET Core






          share|improve this answer

























          • what would that setting be?

            – David
            Nov 14 '18 at 9:27











          • See the updated answer.

            – JKL
            Nov 14 '18 at 9:44












          • That won't help I recently tried to redirect to rhe login page usingRedirect("localhost:5000/account/login); but I needed to build my return url in the query string and that failed.

            – David
            Nov 14 '18 at 10:07












          • Can't you do something like return Redirect("localhost:5000/account/login");?

            – JKL
            Nov 14 '18 at 10:48











          • the redirect url looks like this localhost:5000/account/… I don't know how to build this from scratch

            – David
            Nov 14 '18 at 11:38













          0












          0








          0







          You could add it as a setting in your appsettings.json file.



          I have several ADFS settings stored in this file. An example of how it could look like is this:




          "PublicUrl": "BASE_URL_HERE",
          "ConnectionStrings":
          //Connection strings here
          ,
          "ApplicationInsights":
          "InstrumentationKey": "APPINSIGHTS_INSTRUMENTATIONKEY_HERE"
          ,
          "Logging":
          "IncludeScopes": false,
          "LogLevel":
          "Default": "Error",
          "Microsoft": "Warning",
          "Roxit": "Warning"

          ,
          "Authentication":
          "AdfsBaseUrl": "ADFS_BASEURL_HERE",
          "AdfsLogout": "ADFS_LOGOUT_URL_HERE",
          "AdfsLogin": "ADFS_LOGIN_URL_HERE",




          As you can see I have a logout and login url. How to retrieve these configuration settings in your code you can read here: How to read AppSettings values from Config.json in ASP.NET Core






          share|improve this answer















          You could add it as a setting in your appsettings.json file.



          I have several ADFS settings stored in this file. An example of how it could look like is this:




          "PublicUrl": "BASE_URL_HERE",
          "ConnectionStrings":
          //Connection strings here
          ,
          "ApplicationInsights":
          "InstrumentationKey": "APPINSIGHTS_INSTRUMENTATIONKEY_HERE"
          ,
          "Logging":
          "IncludeScopes": false,
          "LogLevel":
          "Default": "Error",
          "Microsoft": "Warning",
          "Roxit": "Warning"

          ,
          "Authentication":
          "AdfsBaseUrl": "ADFS_BASEURL_HERE",
          "AdfsLogout": "ADFS_LOGOUT_URL_HERE",
          "AdfsLogin": "ADFS_LOGIN_URL_HERE",




          As you can see I have a logout and login url. How to retrieve these configuration settings in your code you can read here: How to read AppSettings values from Config.json in ASP.NET Core







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 14 '18 at 9:43

























          answered Nov 14 '18 at 9:20









          JKLJKL

          17812




          17812












          • what would that setting be?

            – David
            Nov 14 '18 at 9:27











          • See the updated answer.

            – JKL
            Nov 14 '18 at 9:44












          • That won't help I recently tried to redirect to rhe login page usingRedirect("localhost:5000/account/login); but I needed to build my return url in the query string and that failed.

            – David
            Nov 14 '18 at 10:07












          • Can't you do something like return Redirect("localhost:5000/account/login");?

            – JKL
            Nov 14 '18 at 10:48











          • the redirect url looks like this localhost:5000/account/… I don't know how to build this from scratch

            – David
            Nov 14 '18 at 11:38

















          • what would that setting be?

            – David
            Nov 14 '18 at 9:27











          • See the updated answer.

            – JKL
            Nov 14 '18 at 9:44












          • That won't help I recently tried to redirect to rhe login page usingRedirect("localhost:5000/account/login); but I needed to build my return url in the query string and that failed.

            – David
            Nov 14 '18 at 10:07












          • Can't you do something like return Redirect("localhost:5000/account/login");?

            – JKL
            Nov 14 '18 at 10:48











          • the redirect url looks like this localhost:5000/account/… I don't know how to build this from scratch

            – David
            Nov 14 '18 at 11:38
















          what would that setting be?

          – David
          Nov 14 '18 at 9:27





          what would that setting be?

          – David
          Nov 14 '18 at 9:27













          See the updated answer.

          – JKL
          Nov 14 '18 at 9:44






          See the updated answer.

          – JKL
          Nov 14 '18 at 9:44














          That won't help I recently tried to redirect to rhe login page usingRedirect("localhost:5000/account/login); but I needed to build my return url in the query string and that failed.

          – David
          Nov 14 '18 at 10:07






          That won't help I recently tried to redirect to rhe login page usingRedirect("localhost:5000/account/login); but I needed to build my return url in the query string and that failed.

          – David
          Nov 14 '18 at 10:07














          Can't you do something like return Redirect("localhost:5000/account/login");?

          – JKL
          Nov 14 '18 at 10:48





          Can't you do something like return Redirect("localhost:5000/account/login");?

          – JKL
          Nov 14 '18 at 10:48













          the redirect url looks like this localhost:5000/account/… I don't know how to build this from scratch

          – David
          Nov 14 '18 at 11:38





          the redirect url looks like this localhost:5000/account/… I don't know how to build this from scratch

          – David
          Nov 14 '18 at 11:38













          0














          In ASP.Net you'd typically let the cookie authentication middleware handle this - i.e. if you do a HttpContext.SignOut("...my cookie scheme...") or the cookie expires then the next request to a secured action will automatically redirect to the login URL associated with that scheme.



          It's also worth noting that the intention of OpenID Connect is that you'd align the session/auth cookie lifetime of your client web application to that of the IDP session and NOT to the lifetime of an access_token which would typically be much shorter (and renewed silently using a refresh token in a server-side application like this).



          Check out the session management optional spec here:



          https://openid.net/specs/openid-connect-session-1_0.html



          You are of course free to define your own rules for how often an end user of your client must authenticate. You can use the max_age or prompt=login authorize endpoint arguments to force interactive authentication and then check the auth_time claim in the client app to verify that the user was indeed recently authenticated.



          To pass additional parameters using the normal .Net Core 1.1 middleware it might looks like the following (2.x may be slightly different):



          //Initialising OpenIdConnectEvents...
          OnRedirectToIdentityProvider = context =>
          //context.Properties is of type AuthenticationProperties which can be passed via the Challenge() method.
          if(context.Properties.Items.ContainsKey("prompt"))
          context.ProtocolMessage.Prompt = context.Properties.Items["prompt"];






          share|improve this answer

























          • Just to be clear the way I should handle this is to logoff then redirect to my action. This should redirect me to the login page. THe only problem with this is the logoff is not seamless. I need to go to my Auth server logoff page first.

            – David
            Nov 14 '18 at 14:18






          • 1





            @David only if you want to sign out of your auth server too but it doesn't make sense to do that just because a token it issued has expired.

            – mackie
            Nov 14 '18 at 15:09











          • If you can write a small code snippet in asp.net core on how to pass "prompt=login" I'll give you the tick.

            – David
            Nov 15 '18 at 6:55












          • @David See my edit

            – mackie
            Nov 15 '18 at 9:36











          • I tried this.I used await HttpContext.ChallengeAsync("oidc", prop); tp redirect to the Auth server but it just skips I cannot get the auth server login page to display

            – David
            Nov 20 '18 at 18:46
















          0














          In ASP.Net you'd typically let the cookie authentication middleware handle this - i.e. if you do a HttpContext.SignOut("...my cookie scheme...") or the cookie expires then the next request to a secured action will automatically redirect to the login URL associated with that scheme.



          It's also worth noting that the intention of OpenID Connect is that you'd align the session/auth cookie lifetime of your client web application to that of the IDP session and NOT to the lifetime of an access_token which would typically be much shorter (and renewed silently using a refresh token in a server-side application like this).



          Check out the session management optional spec here:



          https://openid.net/specs/openid-connect-session-1_0.html



          You are of course free to define your own rules for how often an end user of your client must authenticate. You can use the max_age or prompt=login authorize endpoint arguments to force interactive authentication and then check the auth_time claim in the client app to verify that the user was indeed recently authenticated.



          To pass additional parameters using the normal .Net Core 1.1 middleware it might looks like the following (2.x may be slightly different):



          //Initialising OpenIdConnectEvents...
          OnRedirectToIdentityProvider = context =>
          //context.Properties is of type AuthenticationProperties which can be passed via the Challenge() method.
          if(context.Properties.Items.ContainsKey("prompt"))
          context.ProtocolMessage.Prompt = context.Properties.Items["prompt"];






          share|improve this answer

























          • Just to be clear the way I should handle this is to logoff then redirect to my action. This should redirect me to the login page. THe only problem with this is the logoff is not seamless. I need to go to my Auth server logoff page first.

            – David
            Nov 14 '18 at 14:18






          • 1





            @David only if you want to sign out of your auth server too but it doesn't make sense to do that just because a token it issued has expired.

            – mackie
            Nov 14 '18 at 15:09











          • If you can write a small code snippet in asp.net core on how to pass "prompt=login" I'll give you the tick.

            – David
            Nov 15 '18 at 6:55












          • @David See my edit

            – mackie
            Nov 15 '18 at 9:36











          • I tried this.I used await HttpContext.ChallengeAsync("oidc", prop); tp redirect to the Auth server but it just skips I cannot get the auth server login page to display

            – David
            Nov 20 '18 at 18:46














          0












          0








          0







          In ASP.Net you'd typically let the cookie authentication middleware handle this - i.e. if you do a HttpContext.SignOut("...my cookie scheme...") or the cookie expires then the next request to a secured action will automatically redirect to the login URL associated with that scheme.



          It's also worth noting that the intention of OpenID Connect is that you'd align the session/auth cookie lifetime of your client web application to that of the IDP session and NOT to the lifetime of an access_token which would typically be much shorter (and renewed silently using a refresh token in a server-side application like this).



          Check out the session management optional spec here:



          https://openid.net/specs/openid-connect-session-1_0.html



          You are of course free to define your own rules for how often an end user of your client must authenticate. You can use the max_age or prompt=login authorize endpoint arguments to force interactive authentication and then check the auth_time claim in the client app to verify that the user was indeed recently authenticated.



          To pass additional parameters using the normal .Net Core 1.1 middleware it might looks like the following (2.x may be slightly different):



          //Initialising OpenIdConnectEvents...
          OnRedirectToIdentityProvider = context =>
          //context.Properties is of type AuthenticationProperties which can be passed via the Challenge() method.
          if(context.Properties.Items.ContainsKey("prompt"))
          context.ProtocolMessage.Prompt = context.Properties.Items["prompt"];






          share|improve this answer















          In ASP.Net you'd typically let the cookie authentication middleware handle this - i.e. if you do a HttpContext.SignOut("...my cookie scheme...") or the cookie expires then the next request to a secured action will automatically redirect to the login URL associated with that scheme.



          It's also worth noting that the intention of OpenID Connect is that you'd align the session/auth cookie lifetime of your client web application to that of the IDP session and NOT to the lifetime of an access_token which would typically be much shorter (and renewed silently using a refresh token in a server-side application like this).



          Check out the session management optional spec here:



          https://openid.net/specs/openid-connect-session-1_0.html



          You are of course free to define your own rules for how often an end user of your client must authenticate. You can use the max_age or prompt=login authorize endpoint arguments to force interactive authentication and then check the auth_time claim in the client app to verify that the user was indeed recently authenticated.



          To pass additional parameters using the normal .Net Core 1.1 middleware it might looks like the following (2.x may be slightly different):



          //Initialising OpenIdConnectEvents...
          OnRedirectToIdentityProvider = context =>
          //context.Properties is of type AuthenticationProperties which can be passed via the Challenge() method.
          if(context.Properties.Items.ContainsKey("prompt"))
          context.ProtocolMessage.Prompt = context.Properties.Items["prompt"];







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 15 '18 at 9:35

























          answered Nov 14 '18 at 13:08









          mackiemackie

          1,99811110




          1,99811110












          • Just to be clear the way I should handle this is to logoff then redirect to my action. This should redirect me to the login page. THe only problem with this is the logoff is not seamless. I need to go to my Auth server logoff page first.

            – David
            Nov 14 '18 at 14:18






          • 1





            @David only if you want to sign out of your auth server too but it doesn't make sense to do that just because a token it issued has expired.

            – mackie
            Nov 14 '18 at 15:09











          • If you can write a small code snippet in asp.net core on how to pass "prompt=login" I'll give you the tick.

            – David
            Nov 15 '18 at 6:55












          • @David See my edit

            – mackie
            Nov 15 '18 at 9:36











          • I tried this.I used await HttpContext.ChallengeAsync("oidc", prop); tp redirect to the Auth server but it just skips I cannot get the auth server login page to display

            – David
            Nov 20 '18 at 18:46


















          • Just to be clear the way I should handle this is to logoff then redirect to my action. This should redirect me to the login page. THe only problem with this is the logoff is not seamless. I need to go to my Auth server logoff page first.

            – David
            Nov 14 '18 at 14:18






          • 1





            @David only if you want to sign out of your auth server too but it doesn't make sense to do that just because a token it issued has expired.

            – mackie
            Nov 14 '18 at 15:09











          • If you can write a small code snippet in asp.net core on how to pass "prompt=login" I'll give you the tick.

            – David
            Nov 15 '18 at 6:55












          • @David See my edit

            – mackie
            Nov 15 '18 at 9:36











          • I tried this.I used await HttpContext.ChallengeAsync("oidc", prop); tp redirect to the Auth server but it just skips I cannot get the auth server login page to display

            – David
            Nov 20 '18 at 18:46

















          Just to be clear the way I should handle this is to logoff then redirect to my action. This should redirect me to the login page. THe only problem with this is the logoff is not seamless. I need to go to my Auth server logoff page first.

          – David
          Nov 14 '18 at 14:18





          Just to be clear the way I should handle this is to logoff then redirect to my action. This should redirect me to the login page. THe only problem with this is the logoff is not seamless. I need to go to my Auth server logoff page first.

          – David
          Nov 14 '18 at 14:18




          1




          1





          @David only if you want to sign out of your auth server too but it doesn't make sense to do that just because a token it issued has expired.

          – mackie
          Nov 14 '18 at 15:09





          @David only if you want to sign out of your auth server too but it doesn't make sense to do that just because a token it issued has expired.

          – mackie
          Nov 14 '18 at 15:09













          If you can write a small code snippet in asp.net core on how to pass "prompt=login" I'll give you the tick.

          – David
          Nov 15 '18 at 6:55






          If you can write a small code snippet in asp.net core on how to pass "prompt=login" I'll give you the tick.

          – David
          Nov 15 '18 at 6:55














          @David See my edit

          – mackie
          Nov 15 '18 at 9:36





          @David See my edit

          – mackie
          Nov 15 '18 at 9:36













          I tried this.I used await HttpContext.ChallengeAsync("oidc", prop); tp redirect to the Auth server but it just skips I cannot get the auth server login page to display

          – David
          Nov 20 '18 at 18:46






          I tried this.I used await HttpContext.ChallengeAsync("oidc", prop); tp redirect to the Auth server but it just skips I cannot get the auth server login page to display

          – David
          Nov 20 '18 at 18:46


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296529%2fhow-to-redirect-to-login-page-when-access-token-and-refresh-token-expires%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Darth Vader #20

          How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

          Ondo