Build a CRUD App with ASP.NET MVC and Entity Framework

Build a CRUD App with ASP.NET MVC and Entity Framework

This post walks through setting up a user managed CRUD app in ASP.NET MVC with Entity Framework.

Madhav Phuyel

Just west my time!! I follow this article because it was written on March 11, 2019 BUT this is not relevant to .NET Core (2.2). Since .NET Core heavily uses Dependency Injection.

Heather Downing

That is correct, @mphuyel . This is for .NET 4.x Framework. If you are interested in the .NET Core version, Chris Green wrote it up in February: https://developer.okta.com/…

eren

Thank you for posting, I just can not handle with how to get user profile information?

leebrandt

Everything in the user’s profile should be in the IClaimsPrincipal. So to get to something like their email address, you have to call User.Identity.Claims.FirstOrDefault(c=>c.Type == ClaimTypes.Email).

Richard W. Memmer

Why are you blaming her for you following an article that made no claim to be .NET Core? You assumed it was .NET Core simply because it was a recent article in this area of interest? That’s a pretty poor assumption – and surely you know better than to do that.

Richard W. Memmer

You handled that with incredible grace! ;o) I look forward to going over this article – thank you!!

Neil Laslett

Thanks for the great guide, but unless I’m doing something very wrong, the Okta setup screens have changed dramatically in the 10 months since this guide was made. Starting with “Create New Application”, nothing looks the same, and I’m having trouble figuring out the changes. For example, I don’t know if I’m supposed to choose SWA, SAML, or OpenID. Also, no “Base URI” field for any of the options.

(I do know what SWA, SAML, and OpenID are and generally what the differences are, but I don’t know which I should use when working with the Okta.AspNet NuGET package.)

Your guide also matches what’s in the official docs, so I’m double-stuck:
https://developer.okta.com/…

Any chance you can update this excellent guide? SSO implementations always make my head spin, so I appreciate the clear walkthrough.

Matt Raible

It sounds like you have a workforce account when you need a developer account. I’d recommend creating a new developer account at https://developer.okta.com/….

cHEn Productions

Thank you! I followed this step by step. After I click login, I would like to see the okta login interface. But I did not see it. How should I do? Is there code I missed please?

Michael Woodman

Thanks for this guide. Can anyone help, I have the worked example all set up with Client ID; Client Secret; my OKTA domain; the project url is set to http://localhost:8080 ; the sign in redirect uri is set to: https://localhost:8080/authorization-code/callback and the sign out redirect uri is set to: https://localhost:8080/Account/PostLogout

When I run the application I get:

https://localhost:8080/authorization-code/callback in the address bar and it errors saying can’t reach this page.

Any help would be greatly appreciated.

Followed code to code but once I login to okta and it redirect back to my app
if (!HttpContext.User.Identity.IsAuthenticated) //this is always true
{
HttpContext.GetOwinContext().Authentication.Challenge(
OktaDefaults.MvcAuthenticationType);
return new HttpUnauthorizedResult();
}

Thus getting too many redirect error. Any suggestion

I am also facing the server error. When I followed the document: Build a CRUD App with ASP.NET MVC and Entity Framework | Okta Developer

After login screen It is redirecting me on http://localhost:8080/authorization-code/callback
with server error.

Please help me to fix this issue.
Thanks in Advance!

Hey @mayank.soni2,
Do you have your sample project available somewhere we can look at? Although I need more details to help, I wonder if this could be a protocol issue, like your app is using https but your config is http.