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
{{ message }}
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: src/Microsoft.AspNetCore.SpaServices/README.md
+18-9Lines changed: 18 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -48,11 +48,14 @@ Instead, what `SpaServices` offers is ASP.NET Core APIs that know how to invoke
48
48
49
49
### 1. Enable the asp-prerender-* tag helpers
50
50
51
-
Make sure you've installed the `Microsoft.AspNetCore.SpaServices` NuGet package and the `aspnet-prerendering` NPM package. Together these contain the server-side and client-side library code you'll need.
51
+
Make sure you've installed into your project:
52
52
53
-
Now go to your `Views/_ViewImports.cshtml` file, and add the following line:
53
+
* The `Microsoft.AspNetCore.SpaServices` NuGet package, version 1.1.0-* or later
54
+
* The `aspnet-prerendering` NPM package, version 2.0.1 or later
54
55
55
-
@addTagHelper *, Microsoft.AspNetCore.SpaServices
56
+
Together these contain the server-side and client-side library code you'll need. Now go to your `Views/_ViewImports.cshtml` file, and add the following line:
@@ -67,7 +70,9 @@ If you run your application now, and browse to whatever page renders the view yo
67
70
Create a JavaScript file at the path matching the `asp-prerender-module` value you specified above. In this example, that means creating a folder called `ClientApp` at the root of your project, and creating a file inside it called `boot-server.js`. Try putting the following into it:
+'<p>Number of cookies: '+params.data.cookies.length+'</p>';
106
113
107
114
resolve({ html: result });
108
115
});
109
-
};
116
+
});
110
117
```
111
118
112
119
Notice that the property names are received in JavaScript-style casing (e.g., `isGoldUser`) even though they were sent in C#-style casing (e.g., `IsGoldUser`). This is because of how the JSON serialization is configured by default.
@@ -182,7 +189,9 @@ If you don't already have a `tsconfig.json` file at the root of your project, ad
182
189
Now you can delete `ClientApp/boot-server.js`, and in its place, create `ClientApp/boot-server.ts`, containing the TypeScript equivalent of what you had before:
Finally, run `webpack` on the command line to build `ClientApp/dist/main-server.js`. Then you can tell `SpaServices` to use that file for server-side prerendering. In your MVC view where you use `aspnet-prerender-module`, update the attribute value:
0 commit comments