# Cannot set PostLogoutRedirectUri

**URL:** <https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797>\
**Category:** Questions\
**Created:** [April 14, 2021, 4:47pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797 "2021-04-14T16:47:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![efinch](https://avatars.discourse-cdn.com/v4/letter/e/b3f665/32.png) [@efinch](https://devforum.okta.com/u/efinch)\
**Post date:** [April 14, 2021, 4:47pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/1 "2021-04-14T16:47:32Z")

</div>

I am using the example located at [samples-aspnetcore/samples-aspnetcore-3x/okta-hosted-login at master · okta/samples-aspnetcore · GitHub](https://github.com/okta/samples-aspnetcore/tree/master/samples-aspnetcore-3x/okta-hosted-login). I have it configured to allow me to log in, but when when I hit the log out button, I get an error saying that my post logout uri is wrong. I added code to set this, but it seems to be getting ignored. How can I properly set PostLogoutRedirectUri ?

Code I added:  
PostLogoutRedirectUri = “[https://localhost:44306/signout-callback-oidc](https://localhost:44306/signout-callback-oidc)”

Actual redirect: signout/callback

Desired redirect: signout-callback-oidc

Error message:  
“The ‘post\_logout\_redirect\_uri’ parameter must be a Logout redirect URI in the client app settings”

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [April 14, 2021, 4:56pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/2 "2021-04-14T16:56:50Z")

</div>

Sounds like you need to add the PostLogoutRedirectUri you configured in OktaMvcOptions as an allowed Logout redirect URI in the Application settings in the Okta admin console (Applications → Application → General → General Settings → Login → Logout redirect URIs), as below:

 ![Screen Shot 2021-04-14 at 9.56.36 AM](https://global.discourse-cdn.com/oktadev/original/2X/6/631906196212f33064473c10a3fcc0754f9212ed.png)

---

<div class="post-metadata">

**Author:** ![efinch](https://avatars.discourse-cdn.com/v4/letter/e/b3f665/32.png) [@efinch](https://devforum.okta.com/u/efinch)\
**Post date:** [April 14, 2021, 5:32pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/3 "2021-04-14T17:32:08Z")

</div>

@andrea , no, I already have that setting on the Okta server. The issue is that this sample application refuses to provide the value that I want as the post\_logout\_redirect\_uri parameter. It keeps setting it to [https://localhost:44306/signout/callback](https://localhost:44306/signout/callback), but I need it to be [https://localhost:44306/signout-callback-oidc](https://localhost:44306/signout-callback-oidc). When I try to set it in code, it doesn’t seem to make any difference.

```
       .AddOktaMvc(new OktaMvcOptions
       {
            // Replace these values with your Okta configuration
           OktaDomain = Configuration.GetValue<string>("Okta:OktaDomain"),
           AuthorizationServerId = Configuration.GetValue<string>("Okta:AuthorizationServerId"),
           ClientId = Configuration.GetValue<string>("Okta:ClientId"),
           ClientSecret = Configuration.GetValue<string>("Okta:ClientSecret"),
           Scope = new List<string> { "openid", "profile", "email" },

           PostLogoutRedirectUri = "https://localhost:44306/signout-callback-oidc", // "signout-callback-oidc", 

       });
```

---

<div class="post-metadata">

**Author:** ![robbsadler](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/robbsadler/32/3794_2.png) [@robbsadler](https://devforum.okta.com/u/robbsadler)\
**Post date:** [March 27, 2022, 1:10pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/4 "2022-03-27T13:10:31Z")

</div>

I am seeing the same behavior:  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/4/42d394436e47b8374357b658cebce3c08db07dd0.png)

Signout generated this request:  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/9/9c300f17f4d11c9d1a9ec5d01af117239b0c4e99.png)  
I did a search across the entire project for signout/callback, and got no results.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [March 29, 2022, 6:15pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/5 "2022-03-29T18:15:36Z")

</div>

Can you instead try setting the URL you want users redirected to after log out has completed within `AuthenticationProperties`, as below:

```auto
[HttpPost]
public IActionResult SignOut()
{
return new SignOutResult(
        new[]
                {
        OktaDefaults.MvcAuthenticationScheme,
        CookieAuthenticationDefaults.AuthenticationScheme,
        },
                new AuthenticationProperties { RedirectUri = "<INSERT-YOUR-POST-URL-HERE>" });
}

```

---

<div class="post-metadata">

**Author:** ![robbsadler](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/robbsadler/32/3794_2.png) [@robbsadler](https://devforum.okta.com/u/robbsadler)\
**Post date:** [March 29, 2022, 6:55pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/6 "2022-03-29T18:55:14Z")

</div>

I believe that is already in place. Here is my current method in that spot:

```auto
        [HttpPost]
        public IActionResult SignOut()
        {
            return new SignOutResult(
                new[]
                {
                     OktaDefaults.MvcAuthenticationScheme,
                     CookieAuthenticationDefaults.AuthenticationScheme,                     
                }
                , new AuthenticationProperties { RedirectUri = "https://localhost:5001/Account/PostSignOut" }
                );
        }

```

---

<div class="post-metadata">

**Author:** ![robbsadler](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/robbsadler/32/3794_2.png) [@robbsadler](https://devforum.okta.com/u/robbsadler)\
**Post date:** [March 31, 2022, 9:27pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/7 "2022-03-31T21:27:01Z")

</div>

I found the /signout/callback reference - it’s in the AspNetCore.dll as a default:

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/1/108389bb8317c938e408e5a0d063de702a055b4a.png)

Not sure why it won’t allow me to override it, or why it wouldn’t work if I create a callback with that uri.

---

<div class="post-metadata">

**Author:** ![jamtay317](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@jamtay317](https://devforum.okta.com/u/jamtay317)\
**Post date:** [April 1, 2022, 1:39pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/8 "2022-04-01T13:39:54Z")

</div>

@robbsadler Thanks! this is helpful! but I need to add a parameter to the `post_logout_redirect_uri`.

so im trying to have `post_logout_redirect_uri=localhost:44306?logoutId=abc123`

how can I add this

---

<div class="post-metadata">

**Author:** ![robbsadler](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/robbsadler/32/3794_2.png) [@robbsadler](https://devforum.okta.com/u/robbsadler)\
**Post date:** [April 1, 2022, 1:53pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/9 "2022-04-01T13:53:46Z")

</div>

I’m trying to find out how to get it to work. I have all of the settings as far as I know, yet it is still using the default setting. But even if I set up a page matching those default settings, it gives me an error. Hopefully we can figure it out.

I started with the generated code from the OKTA CLI, filled in my settings, and had this error right out of the box.

---

<div class="post-metadata">

**Author:** ![robbsadler](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/robbsadler/32/3794_2.png) [@robbsadler](https://devforum.okta.com/u/robbsadler)\
**Post date:** [April 14, 2022, 6:53pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/10 "2022-04-14T18:53:21Z")

</div>

@andrea - any chance you can get us over this hurdle? I guess I could write an ajax call to logout and just throw away the result and redirect to the home page, since the logout is successful but throws this error.

As I mentioned above, this code is right out of the CLI example for .net core. There seems to be something missing in that solution. I don’t believe I made any modifications to the logout other than inserting my particular application configuration per the instructions. I think you could repro by just cloning it and trying to make it work.

Thanks for any assistance - really appreciated!

---

<div class="post-metadata">

**Author:** ![robbsadler](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/robbsadler/32/3794_2.png) [@robbsadler](https://devforum.okta.com/u/robbsadler)\
**Post date:** [April 23, 2022, 12:53pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/11 "2022-04-23T12:53:27Z")

</div>

I want to try and document this carefully so it can be followed up. I no longer need assistance as I have determined the issue, and have a workaround. This seems to be an issue with the expectations of the SDK / OKTA service.

I had tried to simply set my sign-out redirect URI and that failed.

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/d/d0a2ca5ca5504d32ae96236df0650fc4199e77ae.png)

Upon further inspection, I found that regardless of what URI I set in my code, the logout request included the following:

```auto
...post_logout_redirect_uri=https%3A%2F%2Flocalhost%3A5001%2Fsignout%2Fcallback

```

Note that it is set to “/signout/callback”.

In my code I have “/account/postsignout” in both places where this could be set:

In Startup.cs:  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/0/076cf91737b57d1e996ef43cb918d371eb6d02d4.png)

In AccountController Signout:

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/f/f8832ae5a464bfeb50643e302d95019ee64b5ab7.png)

And if I search my code for “signout/callback”, it is nowhere to be found. But the SDK / OKTA service seemed to be stuck on it, so I added it to my application settings and to a controller.

![image](https://global.discourse-cdn.com/oktadev/original/2X/7/7d826dea12d3cb25c1f8f1c53d11270de854a6e2.png)

The result is that the same error appeared. Then the thought occurred to me that it might be case sensitive.

So I changed the setting to be all lowercase:

![image](https://global.discourse-cdn.com/oktadev/original/2X/9/9c570c013fe00f2e6d403130260e2a40556b1fa4.png)

Voila! It started working! So I tried removing the signout/callback controller and just left the setting in the OKTA application sign-out redirect URIs, and it is now working great.

So this may be something to check out on the OKTA side. I am now successfully logging in and out and redirecting.

Hope this is helpful to someone!

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 12, 2024, 7:17pm UTC](https://devforum.okta.com/t/cannot-set-postlogoutredirecturi/13797/12 "2024-02-12T19:17:13Z")

</div>

Closed on February 12, 2024, 7:17pm UTC


