You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/javascript/tutorial-asp-net-core-with-vue.md
+30-19Lines changed: 30 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Create an ASP.NET Core app with Vue"
3
3
description: In this tutorial, you create an app using ASP.NET Core and Vue
4
-
ms.date: 04/25/2023
4
+
ms.date: 08/23/2023
5
5
ms.topic: tutorial
6
6
ms.devlang: javascript
7
7
author: mikejo5000
@@ -28,20 +28,19 @@ You can use the method described in this article to create ASP.NET Core Single P
28
28
- Create the client project based on the framework CLI installed on your computer
29
29
30
30
> [!NOTE]
31
-
> A simplified, updated template is available starting in Visual Studio 2022 version 17.5. This template creates two projects in the initial solution and eliminates several configuration steps compared to the previous template. This article describes the project creation process using the new template.
31
+
> A simplified, updated template is available starting in Visual Studio 2022 version 17.5. This template creates two projects in the initial solution and eliminates several configuration steps compared to the previous template. This article describes the project creation process using the template in Visual Studio 2022 version 17.7, which uses the Vite CLI.
32
32
33
33
## Prerequisites
34
34
35
35
Make sure to install the following:
36
36
37
-
- Visual Studio 2022 version 17.5 or later with the **ASP.NET and web development** workload installed. Go to the [Visual Studio downloads](https://visualstudio.microsoft.com/downloads/?cid=learn-onpage-download-cta) page to install it for free.
37
+
- Visual Studio 2022 version 17.7 or later with the **ASP.NET and web development** workload installed. Go to the [Visual Studio downloads](https://visualstudio.microsoft.com/downloads/?cid=learn-onpage-download-cta) page to install it for free.
38
38
If you need to install the workload and already have Visual Studio, go to **Tools** > **Get Tools and Features...**, which opens the Visual Studio Installer. Choose the **ASP.NET and web development** workload, then choose **Modify**.
39
-
- npm ([https://www.npmjs.com/](https://www.npmjs.com/package/npm)), which is included with Node.js
- npm ([https://www.npmjs.com/](https://www.npmjs.com/package/npm)), which is included with Node.js.
41
40
42
41
## Create the frontend app
43
42
44
-
1. In the Start window (choose **File** > **Start Window** to open), select **Create a new project**.
43
+
1. In the Start window (choose **File** > **Start Window** to open), select **Create a new project**.
45
44
46
45
:::image type="content" source="media/vs-2022/create-new-project.png" alt-text="Screenshot showing Create a new project":::
47
46
@@ -58,13 +57,13 @@ Make sure to install the following:
58
57
Compared to the [standalone Vue template](../javascript/tutorial-create-vue-app.md), you see some new and modified files for integration with ASP.NET Core:
59
58
60
59
- aspnetcore-https.js
61
-
-vue.config.json (modified)
60
+
-vite.config.json (modified)
62
61
- HelloWorld.vue (modified)
63
62
- package.json (modified)
64
63
65
64
## Set the project properties
66
65
67
-
1. In Solution Explorer, right-click the ASP.NET Core project and choose **Properties**.
66
+
1. In Solution Explorer, right-click the ASP.NET Core project (webapi) and choose **Properties**.
68
67
69
68
:::image type="content" source="media/vs-2022/asp-net-core-project-properties.png" alt-text="Screenshot showing Open project properties":::
70
69
@@ -145,40 +144,52 @@ Starting in Visual Studio 2022 version 17.3, you can publish the integrated solu
145
144
You may see the following error:
146
145
147
146
```
148
-
[HPM] Error occurred while trying to proxy request /weatherforecast from localhost:4200 to https://localhost:5001 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
147
+
[HPM] Error occurred while trying to proxy request /weatherforecast from localhost:4200 to https://localhost:5173 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
149
148
```
150
149
151
150
If you see this issue, most likely the frontend started before the backend. Once you see the backend command prompt up and running, just refresh the Vue app in the browser.
152
151
153
-
Otherwise, if the port is in use, try 5002 in *launchSettings.json* and *vue.config.js*.
152
+
Otherwise, if the port is in use, try incrementing the port number by **1** in *launchSettings.json* and *vite.config.js*.
153
+
154
+
### Privacy error
155
+
156
+
You may see the following certificate error:
157
+
158
+
```
159
+
Your connection isn't private
160
+
```
161
+
162
+
Try deleting the Vue certificates from *%appdata%\local\asp.net\https* or *%appdata%\roaming\asp.net\https*, and then retry.
154
163
155
164
### Verify ports
156
165
157
166
If the weather data does not load correctly, you may also need to verify that your ports are correct.
158
167
159
-
1. Make sure that the port numbers match. Go to the *launchSettings.json* file in your ASP.NET Core project (in the *Properties* folder). Get the port number from the `applicationUrl` property.
168
+
1. Make sure that the port numbers match. Go to the *launchSettings.json* file in your ASP.NET Core project (in the *Properties* folder). Get the port number from the `url` or `applicationUrl` property.
160
169
161
-
If there are multiple `applicationUrl` properties, look for one using an `https` endpoint. It should look similar to `https://localhost:5001`.
170
+
If there are multiple `url` or `applicationUrl` properties, look for one using an `https` endpoint. It should look similar to `https://localhost:5173`.
162
171
163
-
1. Then, go to the *vue.config.js* file for your Vue project. Update the target property to match the `applicationUrl` property in *launchSettings.json*. When you update it, that value should look similar to this:
172
+
1. Then, go to the *vite.config.js* file for your Vue project. Update the url or target property to match the`url` or`applicationUrl` property in *launchSettings.json*. When you update it, that value should look similar to this:
164
173
165
174
```js
166
-
target:'https://localhost:5001',
175
+
url:'https://localhost:5173',
167
176
```
168
177
178
+
or:
179
+
169
180
### Outdated version of Vue
170
181
171
-
If you see the console message **Could not find the file 'C:\Users\Me\source\repos\vueprojectname\package.json'** when you create the project, you may need to update your version of the Vue CLI. After you update the Vue CLI, you may also need to delete the *.vuerc* file in *C:\Users\\[yourprofilename\]*.
182
+
If you see the console message **Could not find the file 'C:\Users\Me\source\repos\vueprojectname\package.json'** when you create the project, you may need to update your version of the Vite CLI. After you update the Vite CLI, you may also need to delete the *.vuerc* file in *C:\Users\\[yourprofilename\]*.
172
183
173
184
### Docker
174
185
175
-
If you enable Docker support while creating the web API project, the backend may start up using the Docker profile and not listen on the configured port 5001. To resolve:
186
+
If you enable Docker support while creating the web API project, the backend may start up using the Docker profile and not listen on the configured port 5173. To resolve:
176
187
177
-
Edit the Docker profile in the launchSettings.json by adding the following properties:
188
+
Edit the Docker profile in the *launchSettings.json* by adding the following properties:
0 commit comments