<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z00007B424XCAROkta Classic EngineAuthenticationAnswered2021-09-15T21:58:28.000Z2021-09-13T15:42:58.000Z2021-09-15T21:58:28.000Z

jerryt.05976 (Customer) asked a question.

Getting a HTTP 404 error instead of Okta Hosted Login Form

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:

<add key="okta:ClientId" value="myApplicationClientID" />

  <add key="okta:ClientSecret" value="myApplicationSecretValue" />

  <add key="okta:OktaDomain" value=https://dev-myaccountinfo.okta.com />

  <add key="okta:RedirectUri" value=http://localhost:8080/authorization-code/callback />

  <add key="okta:PostLogoutRedirectUri" value=http://localhost:8080/useraccount/PostLogout />

 

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?

 

 

 

 

 

 


This question is closed.
Loading
Getting a HTTP 404 error instead of Okta Hosted Login Form