aspnetcore-401861-spreadsheet-add-control-to-a-project.md
This topic describes how to build Razor Pages and MVC Web Apps with the Spreadsheet component.
Before start, you should configure your Visual Studio project to use the Spreadsheet component.
If you use a Spreadsheet in a Razor Pages web app, make the following adjustments:
Create a Razor Page. In the page model, implement POST and GET request handlers that return a SpreadsheetRequestProcessor response.
Pass the handler URL to the DocumentRequestHandlerUrl(String) method.
Add an anti‑forgery token to every internal request the Spreadsheet sends to action handlers.
Follow the steps below to add a Spreadsheet to an MVC web page:
Create a new controller or open an existing controller (for example, the HomeController.cs file), and add an action that handles document commands as shown below:
Use the Spreadsheet helper to add a spreadsheet to a Razor file (.cshtml):
To mitigate Cross‑Site Request Forgery (CSRF/XSRF) attacks, add anti‑forgery token validation to the Razor file and controller action.