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-react.md
+20-11Lines changed: 20 additions & 11 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 React"
3
3
description: In this tutorial, you create an app using ASP.NET Core and React
4
-
ms.date: 04/25/2023
4
+
ms.date: 08/24/2023
5
5
ms.topic: tutorial
6
6
ms.devlang: javascript
7
7
author: mikejo5000
@@ -28,13 +28,13 @@ 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
39
- npm ([https://www.npmjs.com/](https://www.npmjs.com/package/npm)), which is included with Node.js
@@ -58,8 +58,7 @@ Make sure to install the following:
58
58
Compared to the [standalone React template](../javascript/tutorial-create-react-app.md), you see some new and modified files for integration with ASP.NET Core:
59
59
60
60
- aspnetcore-https.js
61
-
- aspnetcore-react.js
62
-
- setupProxy.js
61
+
- vite.config.js
63
62
- App.js (modified)
64
63
- App.test.js (modified)
65
64
@@ -152,7 +151,7 @@ Starting in Visual Studio 2022 version 17.3, you can publish the integrated solu
152
151
You may see the following error:
153
152
154
153
```cmd
155
-
[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)
154
+
[HPM] Error occurred while trying to proxy request /weatherforecast from localhost:4200 to https://localhost:7183 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
156
155
```
157
156
158
157
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 React App in the browser.
@@ -161,16 +160,26 @@ If you see this issue, most likely the frontend started before the backend. Once
161
160
162
161
If the weather data does not load correctly, you may also need to verify that your ports are correct.
163
162
164
-
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.
163
+
1. Make sure that the port numbers match. Go to the *launchSettings.json* file in your ASP.NET Core **webapi**project (in the *Properties* folder). Get the port number from the `applicationUrl` property.
165
164
166
-
If there are multiple `applicationUrl` properties, look for one using an `https` endpoint. It should look similar to `https://localhost:7049`.
165
+
If there are multiple `applicationUrl` properties, look for one using an `https` endpoint. It should look similar to `https://localhost:7183`.
167
166
168
-
1. Then, go to the *setupProxy.js* file for your React project (look in the *src* folder). Update the target property to match the `applicationUrl` property in*launchSettings.json*. When you update it, that value should look similar to this:
167
+
1. Then, go to the *vite.config.js* file for your React project. Update the `target` property to match the `applicationUrl` property in *launchSettings.json*. When you update it, that value should look similar to this:
169
168
170
169
```js
171
-
target:'https://localhost:7049',
170
+
target:'https://localhost:7183/',
172
171
```
173
172
173
+
### Privacy error
174
+
175
+
You may see the following certificate error:
176
+
177
+
```
178
+
Your connection isn't private
179
+
```
180
+
181
+
Try deleting the React certificates from *%appdata%\local\asp.net\https* or *%appdata%\roaming\asp.net\https*, and then retry.
182
+
174
183
## Next steps
175
184
176
-
For more information about SPA applications in ASP.NET Core, see the React section under [Developing Single Page Apps](/aspnet/core/client-side/spa/intro#developing-single-page-apps). The linked article provides additional context for project files such as *aspnetcore-https.js*, *aspnetcore-react.js*, and *setupProxy.js*, although details of the implementation are different based on the template differences. For example, instead of a ClientApp folder, the React files are contained in a separate project.
185
+
For more information about SPA applications in ASP.NET Core, see the React section under [Developing Single Page Apps](/aspnet/core/client-side/spa/intro#developing-single-page-apps). The linked article provides additional context for project files such as *aspnetcore-https.js*, although details of the implementation are different based on the template differences. For example, instead of a ClientApp folder, the React files are contained in a separate project.
Copy file name to clipboardExpand all lines: docs/javascript/tutorial-asp-net-core-with-vue.md
+4-6Lines changed: 4 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -165,18 +165,16 @@ Try deleting the Vue certificates from *%appdata%\local\asp.net\https* or *%appd
165
165
166
166
If the weather data does not load correctly, you may also need to verify that your ports are correct.
167
167
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.
168
+
1. Make sure that the port numbers match. Go to the *launchSettings.json* file in your ASP.NET Core **webapi**project (in the *Properties* folder). Get the port number from the `applicationUrl` property.
169
169
170
-
If there are multiple `url` or `applicationUrl` properties, look for one using an `https` endpoint. It should look similar to `https://localhost:5173`.
170
+
If there are multiple `applicationUrl` properties, look for one using an `https` endpoint. It should look similar to `https://localhost:7142`.
171
171
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:
172
+
1. Then, go to the *vite.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:
173
173
174
174
```js
175
-
url:'https://localhost:5173',
175
+
target:'https://localhost:7142/',
176
176
```
177
177
178
-
or:
179
-
180
178
### Outdated version of Vue
181
179
182
180
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\]*.
0 commit comments