# Document Protection in ASP.NET with TX Text Control: Healthcare Use Cases

> This article explores document protection use cases in the healthcare domain. It also explains how to assign usernames, configure edit modes, and use editable regions based on user roles using the Document Editor in an ASP.NET Core application.

- **Author:** Deepika Kathiravan
- **Published:** 2025-06-25
- **Modified:** 2026-07-17
- **Description:** This article explores document protection use cases in the healthcare domain. It also explains how to assign usernames, configure edit modes, and use editable regions based on user roles using the Document Editor in an ASP.NET Core application.
- **7 min read** (1248 words)
- **Tags:**
  - ASP.NET
  - Document Protection
  - Healthcare
  - Document Editor
- **Web URL:** https://www.textcontrol.com/blog/2025/06/25/document-protection-in-asp-dotnet-with-tx-text-control-healthcare-use-cases/
- **LLMs URL:** https://www.textcontrol.com/blog/2025/06/25/document-protection-in-asp-dotnet-with-tx-text-control-healthcare-use-cases/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2025/06/25/document-protection-in-asp-dotnet-with-tx-text-control-healthcare-use-cases/llms-full.txt
- **GitHub Repository:** https://github.com/TextControl/TXTextControl.Web.Core.DocProtectionApp

---

With TX Text Control, document content can be protected by restricting formatting and editing options. Additionally, exceptions can be applied to specific regions within the document and assigned to users with editing permissions. This article explores document protection use cases in the healthcare domain. It also explains how to assign usernames, configure edit modes, and use editable regions based on user roles using the Document Editor in an ASP.NET Core application.

### Document Protection in Healthcare Systems

Document protection is a valuable feature in TX Text Control that can be implemented in healthcare systems. Healthcare providers maintain documents for each patient to store and process important information, such as medical records, forms, and insurance billing. Below are some key use cases that show how document protection can be applied to these documents:

- **Electronic medical and health records (EMR and EHR):** With TX Text Control, developers and users (admins) can protect records from unauthorized edits while allowing specific roles, such as doctors, nurses, or patients, to modify relevant sections by specifying editable regions and user permissions using the ribbon.
- **Consent forms:** Developers can lock the content of the consent form to prevent changes. At the same time, they can allow patients to fill in specific fields, such as their name and signature.
- **Insurance and billing documents:** Editable sections can be assigned to the billing department and patients while keeping the rest of the document protected.

By integrating document protection, hospitals, clinics, and insurance providers ensure data security and accuracy by allowing role-based access control to modify necessary fields. While these are key use cases, TX Text Control's document protection can be applied across various industries beyond healthcare, tailored to individual needs and specific requirements.

> **Learn More**
> 
> To learn more about digital form workflows with electronic signatures and further use cases related to insurance claim forms, refer to these articles:
> 
> [Healthcare Use Case: Digital Forms Workflow with Electronic Signatures ](https://www.textcontrol.com/blog/2023/03/15/healthcare-use-case-digital-forms-workflow-with-electronic-signatures/llms-full.txt)[  
> Use Case: Create, Deploy and Process Insurance Claim Forms ](https://www.textcontrol.com/blog/2023/06/09/use-case-create-deploy-and-process-insurance-claim-forms/llms-full.txt)

### How to Use Document Protection with the TX Text Control Document Editor

> **Tutorial**
> 
> Follow this tutorial to initialize and configure the TX Text Control Document Editor with ASP.NET Core:
> 
> [Getting Started: Document Editor with ASP.NET Core ](https://www.textcontrol.com/blog/2023/09/13/getting-started-document-editor-with-aspnet-core/llms-full.txt)

When applying document protection using TX Text Control, you can choose to fully lock the document, allow certain formatting options, or define editable regions for specific users. All the editing and formatting restrictions apply only when the Editmode is set to *ReadAndSelect*. From a technical perspective, the document is password-encrypted. When this encrypted file is loaded, it remains restricted or read-only. To enable editing, the user must provide the correct password.

This tutorial shows how to create and load a protected document, display the current user, and switch users using a dropdown button to test document protection.

### Create the Protected Document

Assume that you are an admin editor responsible for managing all user-specific actions, such as configuring document permissions. Begin by creating an encrypted document.

> **Learn More**
> 
> Text Control offers options to create an encrypted document, either via the UI or programmatically. Refer to the following articles:
> 
> [Sneak Peek X15: MS Word Compatible Document Protection and Editable Regions ](https://www.textcontrol.com/blog/2017/11/16/ms-word-compatible-editable-regions/llms-full.txt)[  
> X15: Protected Documents Explained Simply ](https://www.textcontrol.com/blog/2017/12/15/protected-documents-explained-simply/llms-full.txt)[  
> X15: Protected Documents Explained Simply - Part II ](https://www.textcontrol.com/blog/2017/12/18/protected-documents-explained-simply-part-2/llms-full.txt)

In this example, a Text Control formatted (.tx) document is generated using the **TX Text Control Words** with encryption enabled. The encrypted document includes editable regions exclusively assigned to the **Doctor** and **Insurer** roles. It is then uploaded to the *Documents* folder of the ASP.NET Core application.

![Create Protected Document](https://s1-www.textcontrol.com/assets/dist/blog/2025/06/25/a/assets/protected_document.webp "Create Protected Document")

### Load the Protected Document, Set Up Usernames, and Edit Modes

To load the protected document and set the default user, update *HomeController.cs* under the *Controllers* folder in your ASP.NET Core MVC application. The following code retrieves the username from the query string, defaulting to the **Insurer** role if none is provided, and sets the path of the encrypted document to be loaded into the view.

```
public IActionResult Index([FromQuery] string? user) 
{ 
    ViewData["User"] = user ?? "Insurer"; 
    ViewData["DocumentPath"] = Path.Combine("Documents", "sampledoc.tx"); 
    return View(); 
}
```

To add the control to the view, open the *Index.cshtml* file located in the *Views/Home folder*. Add the following Razor markup to include the document path and current user.

```
@using TXTextControl.Web.MVC 

@{ 
   var userName = (string) ViewData["User"]!; 
   var docPath = (string) ViewData["DocumentPath"]!; 
}
```

The Editmode can be set to *ReadOnly*, *ReadAndSelect*, or *Edit*. Also, it can be set to *UsePassword*, but this option must be combined exclusively with the *ReadAndSelect* option using a bitwise OR operation. The following code snippet shows how to initialize the Document Editor with the *ReadAndSelect* and *UsePassword* edit modes. A specific username is set (**Insurer** in this case) using the UserNames property that accepts an array of names, where the first entry represents the current user.

```
@Html.TXTextControl().TextControl(settings => 
{ 
  settings.UserNames = new[] { userName }; 
    settings.EditMode = TXTextControl.Web.EditMode.ReadAndSelect | TXTextControl.Web.EditMode.UsePassword; 
}).LoadText(docPath, TXTextControl.Web.StreamType.InternalUnicodeFormat).Render()
```

A dialog box appears, prompting the user to enter a password to unlock the edit mode. This example reproduces a scenario where only the admin editor, or a user with password access, can unlock and edit the protected regions of the document. In the above code, *UsePassword* is enabled to show how password-protected editing looks and works in the Document Editor.

![Load Protected Document](https://s1-www.textcontrol.com/assets/dist/blog/2025/06/25/a/assets/password_protection.webp "Load Protected Document")

### Switch Between User Roles to Test Document Protection

Use the following HTML snippet to simulate logging in as different user roles. It displays the current user, allows role selection via a dropdown, and updates the view based on the selected role when the **"Set User"** button is clicked. The selected username is added to the URL as a query string, letting the page reload with the new user context.

```
<div class="form-group col-lg-5 mt-3"> 
   <p>Logged in as: <strong>@userName</strong></p> 
   <select class="form-control mt-3" id="users"> 
      <option value="Doctor">Doctor</option> 
      <option value="Insurer">Insurer</option> 
   </select> 
   <button onclick="ReloadWithUser()" class="btn btn-success mt-3">Set User</button> 
</div>
```

And the corresponding JavaScript function *ReloadWithUser* is triggered:

```
function ReloadWithUser() { 
   window.location = document.location.origin + 
       document.location.pathname + 
       "?user=" + document.getElementById("users").value; 
}
```

By default, the **Insurer** is set as a current user when the document is initialized. The **Insurer** can edit only the region assigned to the **Insurer** role, as well as any section marked as editable by all users. The **Insurer** does not have permission to edit the region assigned to the **Doctor** role or any fully protected sections. This supports role-based editing and highlights the importance of document protection in managing user-specific access.

![Test Document Protection](https://s1-www.textcontrol.com/assets/dist/blog/2025/06/25/a/assets/insurer_role.webp "Test Document Protection")

The user role is set to **Doctor** when **Doctor** is selected from the dropdown and the **"Set User"** button is triggered:

![Test Document Protection](https://s1-www.textcontrol.com/assets/dist/blog/2025/06/25/a/assets/doctor_role.webp "Test Document Protection")

### Conclusion

This article explains how to use TX Text Control's document protection features in an ASP.NET Core application, including key properties for setting edit modes, usernames, and editable regions. As a result, your application can easily be configured to meet the document protection needs of your business processes.

---

## About Deepika Kathiravan

Deepika Kathiravan is a developer marketing professional, currently Developer Experience Marketing Lead at Text Control. Before moving into marketing, she had almost eight years of experience in various software industry roles. Following her passion for digital media, Deepika relocated to Germany and earned a Master's in Digital Media from the University of Bremen. She now enjoys blending her technical and marketing expertise by creating developer-centered content and driving strategic growth for the brand.

- [LinkedIn](https://www.linkedin.com/in/deepikakathiravan/)

---

## Related Posts

- [Introducing TX Text Control Web Collaboration Preview for ASP.NET Core](https://www.textcontrol.com/blog/2026/08/05/introducing-tx-text-control-web-collaboration-preview-for-asp-net-core-document-editors/llms.txt)
- [Beyond WebSockets: A Glimpse into the Future of Document Editing with WebAssembly](https://www.textcontrol.com/blog/2026/06/10/beyond-websockets-glimpse-future-document-editing-webassembly/llms.txt)
- [5 Layout Patterns for Integrating the TX Text Control Document Editor in ASP.NET Core C#](https://www.textcontrol.com/blog/2026/04/09/5-layout-patterns-for-integrating-the-tx-text-control-document-editor-in-aspnet-core-csharp/llms.txt)
- [Introducing Text Control Agent Skills](https://www.textcontrol.com/blog/2026/03/27/introducing-text-control-agent-skills/llms.txt)
- [Deploying the TX Text Control Document Editor from the Private NuGet Feed to Azure App Services (Linux and Windows)](https://www.textcontrol.com/blog/2026/03/25/deploying-the-tx-text-control-document-editor-from-the-private-nuget-feed-to-azure-app-services-linux-and-windows/llms.txt)
- [Build a Custom Backstage View in ASP.NET Core with TX Text Control](https://www.textcontrol.com/blog/2026/02/17/build-a-custom-backstage-view-in-aspnet-core-with-tx-text-control/llms.txt)
- [ASP.NET Core Document Editor with Backend via the Text Control Private NuGet Feed](https://www.textcontrol.com/blog/2026/02/09/aspnet-core-document-editor-private-nuget-feed/llms.txt)
- [Why Document Processing Libraries Require a Document Editor](https://www.textcontrol.com/blog/2025/12/04/why-document-processing-libraries-require-a-document-editor/llms.txt)
- [Getting Started Video Tutorial: Document Editor in ASP.NET Core C# on Linux](https://www.textcontrol.com/blog/2025/07/29/getting-started-video-tutorial-document-editor-aspnet-core-csharp-linux/llms.txt)
- [Deploying the TX Text Control Document Editor in an ASP.NET Core Web App to Azure App Services](https://www.textcontrol.com/blog/2025/03/26/deploying-the-tx-text-control-document-editor-in-an-asp-net-core-web-app-to-azure-app-services/llms.txt)
- [Building an ASP.NET Core Backend (Linux and Windows) for the Document Editor and Viewer](https://www.textcontrol.com/blog/2025/03/26/building-an-asp-net-core-backend-for-the-document-editor-and-viewer/llms.txt)
- [TX Text Control for Blazor: Mail Merge Integration Tutorial](https://www.textcontrol.com/blog/2025/03/25/tx-text-control-for-blazor-mail-merge-integration-tutorial/llms.txt)
- [TX Text Control Document Editor and Viewer for Blazor Released](https://www.textcontrol.com/blog/2025/03/25/tx-text-control-document-editor-and-viewer-for-blazor-released/llms.txt)
- [Getting Started: Document Editor for Blazor in ASP.NET Core](https://www.textcontrol.com/blog/2025/03/25/getting-started-document-editor-for-blazor-in-asp-net-core/llms.txt)
- [Introducing TXTextControl.Web.Server.Core: A Cross-Platform Backend for TX Text Control Document Editor](https://www.textcontrol.com/blog/2025/03/13/introducing-txtextcontrol-web-server-core-a-cross-platform-backend-for-tx-text-control-document-editor/llms.txt)
- [Getting Started: Document Editor with ASP.NET Core and Docker Support with Linux Containers](https://www.textcontrol.com/blog/2025/03/12/getting-started-document-editor-with-asp-net-core-and-docker-support-with-linux-containers/llms.txt)
- [Announcing Our Work on a Blazor Component for Document Editing and Viewing](https://www.textcontrol.com/blog/2025/01/24/announcing-our-work-on-a-blazor-component-for-document-editing-and-viewing/llms.txt)
- [Preparing Documents for E-Signing for Multiple Signers in .NET C#](https://www.textcontrol.com/blog/2024/11/13/preparing-documents-for-e-signing-for-multiple-signers-in-net-c-sharp/llms.txt)
- [ASP.NET Core: Use the Document Editor and Viewer in the Same Razor View](https://www.textcontrol.com/blog/2024/11/08/asp-net-core-use-the-document-editor-and-viewer-in-the-same-razor-view/llms.txt)
- [Connecting the TXWebSocketMiddleware to a Separate, External TCP Synchronization Service](https://www.textcontrol.com/blog/2024/10/01/connecting-the-txwebsocketmiddleware-to-a-separate-external-tcp-synchronization-service/llms.txt)
- [Getting Started: Creating an ASP.NET Core Web App with the Document Editor in Visual Studio Code (VS Code)](https://www.textcontrol.com/blog/2024/09/27/getting-started-creating-an-asp-net-core-web-app-with-the-document-editor-in-visual-studio-code-vs-code/llms.txt)
- [Getting Started Video Tutorial: How to use the Document Editor in ASP.NET Core C#](https://www.textcontrol.com/blog/2024/08/05/getting-started-video-tutorial-how-to-use-the-document-editor-in-asp-net-core-csharp/llms.txt)
- [Observe When the Reporting Preview Tab is Active Using MutationObserver](https://www.textcontrol.com/blog/2024/07/23/observe-when-the-reporting-preview-tab-is-active-using-mutationobserver/llms.txt)
- [Removing Empty Pages in TX Text Control with JavaScript](https://www.textcontrol.com/blog/2024/06/19/removing-empty-pages-in-tx-textcontrol-with-javascript/llms.txt)
- [ASP.NET Core: Loading Documents in the Document Editor](https://www.textcontrol.com/blog/2024/04/15/asp-net-core-how-to-load-a-document-in-the-document-editor/llms.txt)
