I am having trouble getting the Okta login window to appear in my “test” MVC app. When I click my login link, I get this error:
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed…
Requested URL: /login.aspx
I followed the docs on Adding OKTA Authentication to an Aspnet application.
I setup the application in okta with these parameters:
Sign-in redirect URIs: http://localhost:8080/authorization-code/callback
Sign-out redirect URIs: http://localhost:8080/UserAccount/Logout
Initiate login URI: http://localhost:8080/
My web.config has these application settings:
I added this to my Home page:
@if (Context.User.Identity.IsAuthenticated)
{
<p>Hello, <b>@Context.User.Identity.Name</b></p>
}
else
{
<li>@Html.ActionLink("Sign In", "Login", "UserAccount")</li>
}
My UserAccountController.cs Login() method is set like this:
public ActionResult Login()
{
if (!HttpContext.User.Identity.IsAuthenticated)
{
HttpContext.GetOwinContext().Authentication.Challenge(
OktaDefaults.MvcAuthenticationType);
return new HttpUnauthorizedResult();
}
return RedirectToAction("Index", "Home");
}
I added an OWIN startup class as suggested. And the Configuration() method is run when the app starts.
When I start my app and click the login link, the Login() method is called in my UseraccountController. But when this line is hit, I get the above error: return new HttpUnauthorizedResult()
The docs say I should see the Okta hosted login form.
What am I missing?