# CORS issue when attempting to logout from .NET Core Application

**URL:** <https://community.auth0.com/t/cors-issue-when-attempting-to-logout-from-net-core-application/22552>\
**Category:** Get Help\
**Tags:** cors\
**Created:** [March 13, 2019, 6:50am UTC](https://community.auth0.com/t/cors-issue-when-attempting-to-logout-from-net-core-application/22552 "2019-03-13T06:50:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![henry.delgado](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/henry.delgado/32/11749_2.png) [@henry.delgado](https://community.auth0.com/u/henry.delgado)\
**Post date:** [March 13, 2019, 6:50am UTC](https://community.auth0.com/t/cors-issue-when-attempting-to-logout-from-net-core-application/22552/1 "2019-03-13T06:50:04Z")

</div>

I am currently following one of the quick starts for implementing Oauth2 on .NET Core 2.2 (Regular Web application).  
I can login successfully but I am having issues logging out.

I am using Chrome and have tried to even install the CORS plug in. I see several blogs and questions on this but do not solve my issue. I am using port 5000 when developing against my local environment and I have ensured that my Auth0 settings have the proper callbacks and other Urls.

 ![auth0](https://global.discourse-cdn.com/auth0/original/2X/8/81e0a2feafe76c49cb4aa08b766e08b501878b32.png)  
 ![auth0-2](https://global.discourse-cdn.com/auth0/original/2X/3/3149b807967e73809b107fd7f177771aecb2564c.png)  
 ![auth0-3](https://global.discourse-cdn.com/auth0/original/2X/7/789949e6eda010152e778ef87ebfb5b3f3a7a5d0.png)

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [March 13, 2019, 11:55am UTC](https://community.auth0.com/t/cors-issue-when-attempting-to-logout-from-net-core-application/22552/3 "2019-03-13T11:55:19Z")

</div>

From the information provided it seems the issue is that you’re trying to call the logout endpoint using XHR which would indeed be subject to CORS. Given that the server side implementation of your logout endpoint issues an HTTP redirect the browser, then as part of the XHR response handling the browser will try to follow the redirect and this ultimately leads to the CORS issue.

I’m afraid that the above is mostly expected as the logout endpoint expectations is that it will be called as part a regular top-level window navigation which would not be subject to CORS.

In other words, you should not call your own logout endpoint through XHR and instead perform a regular navigation to its URL. The response will then issue the redirect to Auth0, terminate the session and navigate back to your application (`returnTo` parameter). In this flow you will not have any CORS issue because the way you perform the requests won’t be subject to the browser CORS policy.

---

<div class="post-metadata">

**Author:** ![henry.delgado](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/henry.delgado/32/11749_2.png) [@henry.delgado](https://community.auth0.com/u/henry.delgado)\
**Post date:** [March 13, 2019, 1:57pm UTC](https://community.auth0.com/t/cors-issue-when-attempting-to-logout-from-net-core-application/22552/4 "2019-03-13T13:57:31Z")

</div>

Hi @jmangelo, thanks for the prompt response.  
I think that I am facing this issue as a result of following the suggested Quick Start code.  
Everything else that you say makes sense. It would be good to update those examples because it might continue to confuse more people and your team might have this issues reported again.

Thank you again, and I will try to come up with that code. I will not use those Quick Starts.  
Enjoy your day

Henry Delgado

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [March 14, 2019, 4:24pm UTC](https://community.auth0.com/t/cors-issue-when-attempting-to-logout-from-net-core-application/22552/5 "2019-03-14T16:24:22Z")

</div>

I confess I haven’t run the .NET quickstart recently, but I’ll put a reminder to check the existing samples because using XHR for logout is indeed unexpected. Thanks for letting me know about that situation.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 29, 2019, 4:24pm UTC](https://community.auth0.com/t/cors-issue-when-attempting-to-logout-from-net-core-application/22552/6 "2019-03-29T16:24:26Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
