Search code examples
asp.netwifclaims-based-identity

How do I programmatically redirect an unauthenticated request to an STS?


I need unauthenticated users to first be redirected to a login page on an ASP.NET website, then I'll do some business logic to determine one of three authentication types:

  1. the user will manually log in with a username and password
  2. the user will get redirected to an STS for a federated login
  3. or (in some cases) the user does not require a login at all and the system will just set their IsAuthenticated=true so they can continue on in their process.

My question is, if it's option #2, how do I programmatically redirect a request to an STS like if I had checked the option in the image below to "Redirect all unauthenticated requests to the STS"?

enter image description here


Solution

  • What we had to do what set it to "Redirect all unauthenticated requests to the STS" and then look in the ISS logs on the receiving Active Directory server to see what the URL looked like that is was redirecting to. Then we were able to build the URL on the fly from the Login.aspx page and redirect manually when necessary.