Getting a HTTP 404 error instead of Okta Hosted Login Form - ASP.NET MVC

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?

Hello,

Have you tried to run this sample,

Yes. Tried with same example.
Strange part is, its working on the other solution. But when I integrate with my project, its redirecting to /login.aspx with HTTP 404 code.

Have you checked this Microsoft forum Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. it might be related.

Thank you for the reference link.
Yeah. I think issue is not related to “path/file not found”. It’s not applying the OAuth configurations, though the owin class and configs are read.
Similar setting working for othe proj.