Click here to Skip to main content
14,920,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to use Response.Redirect("url") to go to keycloak and then back and process the return url from the browser. But, when kecloak send the response, my view load again and execute the Redirect too. So, the infinite loop occurs. Thanks

What I have tried:

C#
        public ActionResult Index()
        {

            Response.Redirect("urlToKecloakRealm",false);
            string url = Request.Url.AbsoluteUri; //I want catch the response url, but this is not happening.

            return View("Custom", url);
}
Posted
Updated 28-Jan-21 11:50am

1 solution

Here's your code:
C#
Response.Redirect("urlToKecloakRealm",false);

string url = Request.Url.AbsoluteUri; //I want catch the response url, but this is not happening.


Did you notice that you said you want to "catch the response url, but this is not happening"

However, the code is showing:
Request.Url.AbsoluteUri;
You've got Request there.
Are you simply referring to the wrong object?
Or did you state it incorrectly?
Just checking on that. Maybe this will help. :)
   
Comments
Mauzz13 29-Jan-21 7:36am
   
Thanks for your reply. The thing is that when the response from Keycloak is back, the Index ActionResult is triggered again and Response.Redirect too. This is generate a infinite loop and not allow to catch the response url. Thanks again.
raddevus 29-Jan-21 8:45am
   
Try...
return null;
instead of the...
return View()
I think you may be pleasantly surprised. If this works, you can determine some way to return null when you want.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900