Getting Started with ASP.NET MVC DOCX Editor

21 Jul 20263 minutes to read

Syncfusion® ASP.NET MVC DOCX Editor (Document Editor) enables you to create, edit, view, and print Word documents in web applications. This section guides you through the steps to get started and create a DOCX Editor in an ASP.NET MVC application.

Prerequisites

Create ASP.NET MVC application with HTML helper

Install Syncfusion® ASP.NET MVC NuGet packages

To add the DOCX Editor component in the application, follow the steps below.

  • Open NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution),
  • Search and install the following package

Alternatively, you can utilize the following package manager command to achieve the same.

Install-Package Syncfusion.EJ2.MVC5

NOTE

This package includes dependencies such as Newtonsoft.Json for JSON serialization and Syncfusion.Licensing for license validation.

Add namespace

Add the Syncfusion.EJ2 namespace reference to the <namespaces> section in the ~/Views/Web.config file.

<add namespace="Syncfusion.EJ2"/>

Register a Syncfusion License Key

Before initializing the ASP.NET MVC DOCX Editor control, generate a Syncfusion license key and register it in your application.

Add the stylesheet and script resources

To render Syncfusion ASP.NET MVC controls with the expected appearance, reference the theme stylesheet and the control scripts via CDN inside the <head> of the ~/Views/Shared/_Layout.cshtml file as follows,

<!-- Syncfusion ASP.NET MVC controls styles -->
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/34.2.2/fluent.css" />
<!-- Syncfusion ASP.NET MVC controls scripts -->
<script src="https://cdn.syncfusion.com/ej2/34.2.2/dist/ej2.min.js"></script>

NOTE

Refer the Themes topic to learn the different ways to include Syncfusion styles (using CDN, NPM package, or CRG) and ensure the expected appearance of Syncfusion® ASP.NET MVC controls, and check the Adding Script Reference documentation to understand the various approaches for adding required script references in your ASP.NET MVC application.

Register script manager

Register the Script Manager at the end of the <body> tag in the ~/Views/Shared/_Layout.cshtml file, as shown below.

<!-- Syncfusion ASP.NET MVC Script Manager -->
@Html.EJS().ScriptManager()

Add the DOCX Editor Component

Add the DOCX Editor component in ~/Views/Home/Index.cshtml page.

@Html.EJS().DocumentEditorContainer("container").Height("590px").Render()

Run the application

Press Ctrl+F5 to run the app. The DOCX Editor component will then be rendered in the default web browser as shown below.

Output of ASP.NET MVC DOCX Editor

NOTE

View Sample in GitHub.

Online Demo

Explore how to create, edit, and print Word documents using the ASP.NET MVC DOCX Editor in this live demo here.

NOTE

Looking for the full ASP.NET MVC DOCX Editor component overview, features, pricing, and documentation? Visit the ASP.NET MVC DOCX Editor page.

Troubleshooting

If the DOCX Editor control does not render as expected, use the following checklist to resolve the most common setup and configuration issues.

1. DOCX Editor not rendering

  • Confirm that @Html.EJS().ScriptManager() is included before the closing </body> tag and check the browser console for JavaScript errors.

2. Licensing errors at runtime

  • Ensure that you have registered your Syncfusion license before deploying the application to production.

See also