# Build a Simple CRUD App with ASP.NET Core and Vue

**URL:** <https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920>\
**Category:** Developer Blog Comments\
**Created:** [August 27, 2018, 3:06pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920 "2018-08-27T15:06:29Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [August 27, 2018, 3:06pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/1 "2018-08-27T15:06:29Z")

</div>

[Build a Simple CRUD App with ASP.NET Core and Vue](https://developer.okta.com/blog/2018/08/27/build-crud-app-vuejs-netcore)

This tutorial walks you through building a basic CRUD application with [ASP.NET](http://ASP.NET) Core and Vue.js.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [September 26, 2018, 8:21pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/2 "2018-09-26T20:21:01Z")

</div>

**Keith Lewis**

I was going through this and got an error: ‘FoodRecords is not an Object’. Going through the code I determined an issue with the code. You never import the FoodRecords component in your router/index.js. The following needs to be added to router/index.js:

```
import FoodRecords from ‘@/components/FoodRecords’
```

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [September 26, 2018, 9:07pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/3 "2018-09-26T21:07:57Z")

</div>

**Keith Lewis**

Additionally, when it tries to do the okta auth, I am directed to

```
{my_Okta_Domain}/oauth2/default/v1/authorize?client_id={my_Client_ID}&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fimplicit%2Fcallback&response_type=id_token token&response_mode=fragment&state={state}&nonce={nonce}&scope=openid profile email 
```

and receive a 400 ‘Bard Request’ error. I have white-listed   
[http://localhost:8080/implicit.callback](http://localhost:8080/implicit.callback)  
&  
[http://localhost](http://localhost)%3A8080%2Fimplicit%2Fcallback

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [September 26, 2018, 9:52pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/4 "2018-09-26T21:52:54Z")

</div>

**Keith Lewis**

I noticed some issues with the FoodRecords.vue. your code shows the b-alert element with an extra space between the colon and show but it should look like this:

```
<b-alert :show=“loading” variant=“info”>Loading…</b-alert>
```

This also happens in b-card element between colon and title where it should be:

```
<b-card :title="(model.id ? ‘Edit Food ID#’ + model.id : ‘New Food Record’)">
```

and in the tr for the table where it should be:

```
<tr v-for=“record in records” :key=“record.id”>
```

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [November 28, 2018, 1:19am UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/5 "2018-11-28T01:19:48Z")

</div>

**lopchoi53**

Hi Ibrahim Šuta, how to up vue and [asp.net](http://asp.net "asp.net") core to hosting together?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [December 6, 2018, 9:34pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/6 "2018-12-06T21:34:49Z")

</div>

**Deveron Crawford**

Namespaces! Why are they not included in your sample code? It took me a while (3 days, in fact) to realize that FoodRecords.cs should have “using System;” before the class declaration, and Startup.cs needs

using AspNetCore.Controllers;  
using Microsoft.EntityFrameworkCore;

to resolve all of it’s references.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [December 10, 2018, 10:58pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/7 "2018-12-10T22:58:20Z")

</div>

**arcooke**

Great article, thanks for this. I have one problem with the demo project I’m not sure how to solve. I added `meta: { requiresAuth: true }` to the `/` route. When I’m logged out and navigate to localhost, my app fully loads and appears in the browser for a split second before being redirected to the Okta login page. How can I prevent any rendering from occurring before redirect?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [January 2, 2019, 1:37pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/8 "2019-01-02T13:37:40Z")

</div>

**Mika Gouzee**

Hello

Thanks for the work. Interesting. Just a question : in the appsettings for the aspnetcore app, you wrote a ClientSecret line. However, when configurated as a SPA, there’s no Client Secret to be found in Okta’s configuration.   
Could you provide more explanation here ? is it something that changed recently, or were you distracted ?

Thanks

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [January 8, 2019, 5:48pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/9 "2019-01-08T17:48:16Z")

</div>

**leebrandt**

The SPA app uses the implicit flow for authentication and doesn’t require a client secret. The newer guidance would be to look at the Auth Code flow with PKCE like Mobile apps do. [https://developer.okta.com/…](https://developer.okta.com/blog/2018/12/13/oauth-2-for-native-and-mobile-apps "https://developer.okta.com/blog/2018/12/13/oauth-2-for-native-and-mobile-apps")

Hope this helps!

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [March 17, 2019, 7:52pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/10 "2019-03-17T19:52:06Z")

</div>

**Philipp Grigoryev**

Weird thing, when I try to open FoodTracker page, it comes empty. Not sure how to troubleshoot a possible issue. npm doesn’t show any issues while running…

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [March 26, 2019, 4:33pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/11 "2019-03-26T16:33:27Z")

</div>

**leebrandt**

All you should need in trusted origins is [http://localhost:8080](http://localhost:8080) which should be added automatically for you when you create the application in Okta. is [http://localhost:8080](http://localhost:8080) not in your trusted origins?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [March 26, 2019, 4:49pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/12 "2019-03-26T16:49:30Z")

</div>

**Keith Lewis**

this is what shows: [https://uploads.disquscdn.c…](https://uploads.disquscdn.com/images/2d91cb5f26b94f264b15c4512f27ce104186b2e7ad83908d0489d2b92ab879af.png "https://uploads.disquscdn.com/images/2d91cb5f26b94f264b15c4512f27ce104186b2e7ad83908d0489d2b92ab879af.png")

I don’t know if the trailing Implicit.callback is waht is causing it or not, and I don’t have this stood up any more. Some point soon, I will look and see if I can find the time to stand it back up.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [April 25, 2020, 11:50am UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/13 "2020-04-25T11:50:35Z")

</div>

**mihai vancsa**

hei, i get this error: The type or namespace name ‘JwtBearer’ does not exist in the namespace ‘Microsoft.AspNetCore.Authentication’   
Can someone help me with it?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [May 1, 2020, 5:04pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/14 "2020-05-01T17:04:08Z")

</div>

**antikonservativ**

Just run this in terminal:  
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer --version 3.0.0

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [June 16, 2020, 7:53pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/15 "2020-06-16T19:53:12Z")

</div>

**Eric Brown**

Confused,:

you say   
Inside of your main folder food-records navigate to AspNetCore folder and run the following:

I don’t have a food-records folder, I’ve been following till then, can you give more context?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 23, 2020, 9:58am UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/16 "2020-07-23T09:58:23Z")

</div>

**Fabian Rhoda**

What about rolebased authorization in the ModelController in [Asp.net](http://Asp.net "Asp.net") Core? Something linke [Authorize(Role=“Admin”)] instead of simple [Authorize] annotation?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [November 5, 2020, 11:20pm UTC](https://devforum.okta.com/t/build-a-simple-crud-app-with-asp-net-core-and-vue/16920/17 "2020-11-05T23:20:20Z")

</div>

**vinod patil**

From where you copied the client secretkey in appsetting.json??
