# Asp.net OWIN - Infinite loop when trying to use roles

**URL:** <https://community.auth0.com/t/asp-net-owin-infinite-loop-when-trying-to-use-roles/18912>\
**Category:** Get Help\
**Created:** [December 10, 2018, 5:00pm UTC](https://community.auth0.com/t/asp-net-owin-infinite-loop-when-trying-to-use-roles/18912 "2018-12-10T17:00:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![only\_me\_jo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/only_me_jo/32/9737_2.png) [@only\_me\_jo](https://community.auth0.com/u/only_me_jo)\
**Post date:** [December 10, 2018, 5:00pm UTC](https://community.auth0.com/t/asp-net-owin-infinite-loop-when-trying-to-use-roles/18912/1 "2018-12-10T17:00:06Z")

</div>

Hi everyone,

I’ve tried to test the Auth0 integration with an [ASP.NET](http://ASP.NET) 4.6.1 application by using the following quickstart:

[https://auth0.com/docs/quickstart/webapp/aspnet-owin/03-authorization](https://auth0.com/docs/quickstart/webapp/aspnet-owin/03-authorization)

I downloaded the example and hooked it up with my default app, added the roles rule as per the tutorial and if I try to access the /Account/Admin route with an “admin” role, everything works as expected.

The problem appears when I try to access this route with any other role.

Expected result: I am redirected to the homepage (or the callback url of my choice).

Actual result: The app starts an infinite loop that ends with a “_“OpenIdConnectMessage.Error was not null, indicating an error. Error: ‘access\_denied’. Error\_Description (may be empty): ‘’. Error\_Uri (may be empty): ‘’.”_” error.

I tried investigating myself but I am out of ideas. Has anyone else encountered this?

**In case it helps anyone, easiest way to reproduce:**

- use the example code provided in the quickstart
- assign the user a “user” role (in the example’s case, the user’s email should not end with “[example.com](http://example.com)”)
- try to access the /Account/Admin route

Thanks!

---

<div class="post-metadata">

**Author:** ![charsleysa](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/charsleysa/32/9722_2.png) [@charsleysa](https://community.auth0.com/u/charsleysa)\
**Post date:** [December 11, 2018, 1:33am UTC](https://community.auth0.com/t/asp-net-owin-infinite-loop-when-trying-to-use-roles/18912/2 "2018-12-11T01:33:17Z")

</div>

Hi @only_me_jo

This seems to be a legacy implementation issue with [ASP.NET](http://ASP.NET), in short it creates a redirect loop as it redirects to the login page which in turn redirects back to the page it was trying to request (which in this case is `/Account/Admin`).

You can read more about it in [this blog post](https://www.blinkingcaret.com/2016/01/20/authorization-redirect-loops-asp-net-mvc/) (which contains a potential solution that you can customize).

Hope this helps!

---

<div class="post-metadata">

**Author:** ![jamie](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jamie/32/12805_2.png) [@jamie](https://community.auth0.com/u/jamie)\
**Post date:** [July 8, 2019, 4:06pm UTC](https://community.auth0.com/t/asp-net-owin-infinite-loop-when-trying-to-use-roles/18912/3 "2019-07-08T16:06:17Z")

</div>

I’ve also just pulled the quick start project and tried it and I still have the same issue. I have tried using the CustomAuthroizeAttribute but it doesn’t seem to work, as I still get in the same loop

---

<div class="post-metadata">

**Author:** ![tom1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tom1/32/17617_2.png) [@tom1](https://community.auth0.com/u/tom1)\
**Post date:** [January 16, 2020, 9:08pm UTC](https://community.auth0.com/t/asp-net-owin-infinite-loop-when-trying-to-use-roles/18912/4 "2020-01-16T21:08:37Z")

</div>

Also getting this, it looks like if you don’t have permission, it redirects you back to auth0, when it should throw a permission error, since you are authenticated, but not authorized.
