file-handling

Implements secure file uploads, streaming, and storage abstractions for ASP.NET Core Razor Pages.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill file-handling-agibuild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: file-handling
Source: https://github.com/AGIBuild/dotnet.CI.template/tree/main/.cursor/skills/file-handling
Command: npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill file-handling-agibuild

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? File handling in web applications introduces security risks like path traversal, malicious uploads, and memory exhaustion from large files. This Skill provides validated patterns for secure, performant file operations in ASP.NET Core Razor Pages applications. ## Core Features & Use Cases - Secure Upload Validation: Validate file size, extension, and content using magic number signatures to block disguised malicious files. - Large File Streaming: Stream multipart uploads directly to storage without loading entire files into memory, supporting files up to 500MB. - Storage Abstraction: Swap between local file system and Azure Blob Storage through a common IFileStorageService interface. - Use Case: Build a document upload page where users submit PDFs up to 10MB, validate the content matches the declared type, stream it to Azure Blob Storage, and serve downloads through authorized, opaque file IDs. ## Quick Start Implement a secure file upload page in my Razor Pages app with size limits, file signature validation, and streaming to Azure Blob Storage.

Frequently Asked Questions about file-handling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I validate file uploads in ASP.NET Core Razor Pages?▼

Validate file uploads by checking file size against configured limits, verifying the extension against an allowlist, and reading magic number signatures to confirm content matches the declared type. Never trust the file extension alone since malicious files can use safe-looking extensions.

How to upload large files in ASP.NET Core without memory issues?▼

Use MultipartReader to stream request sections directly to storage instead of buffering with IFormFile. Set RequestSizeLimit and RequestFormLimits attributes to allow large bodies, then copy section streams to your storage backend without loading the full file into memory.

Should I use local file storage or Azure Blob Storage for uploads?▼

Local file storage works for single-server deployments and development, while Azure Blob Storage suits distributed or scaled-out applications. Abstract both behind an IFileStorageService interface so you can swap implementations through configuration without changing page code.

How do I prevent path traversal attacks in file uploads?▼

Prevent path traversal by calling Path.GetFileName on user-supplied filenames to strip directory components, then generate a new GUID-based filename for storage. Never combine raw user filenames with server paths, and return opaque file IDs instead of internal paths.

Why does my file upload fail for files over 30MB in ASP.NET Core?▼

ASP.NET Core enforces default request body and multipart limits around 28-30MB. Raise them with the RequestSizeLimit and RequestFormLimits attributes on your page handler, and configure Kestrel or IIS max request body size if hosting limits still block the upload.