FileServerPlus.Mvc
1.0.1
dotnet add package FileServerPlus.Mvc --version 1.0.1
NuGet\Install-Package FileServerPlus.Mvc -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FileServerPlus.Mvc" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FileServerPlus.Mvc" Version="1.0.1" />
<PackageReference Include="FileServerPlus.Mvc" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FileServerPlus.Mvc --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FileServerPlus.Mvc, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FileServerPlus.Mvc@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FileServerPlus.Mvc&version=1.0.1
#tool nuget:?package=FileServerPlus.Mvc&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
File server extensions of ASP.NET Core
An extensions of file server on ASP.NET core to support file version.
Normal (Framework not generate version if use file server)
<img class="d-block m-auto" src="/storage1/cat.jpg" width="200" alt="Sample cat">
File server Plus
<img class="d-block m-auto" src="/storage1/cat.jpg?v=vW8o-DqXyVVm8IQWxIOh8eFuv91UvMW9uJ2ei1a2vX8" width="200" alt="Sample cat">
Installation
Install-Package FileServerPlus.Mvc -Version 1.0.0
Get Started
Register
1. Views/_ViewImports.cshtml
// _ViewImports.cshtml
@using FileServerPlus.Mvc.Extensions
...
@addTagHelper *, FileServerPlus.Mvc
2. Configure services
// Startup.cs
public void ConfigureServices(IServiceCollection services)
{
...
services.AddFileServerPlus();
}
3. Configure directory
3.1 Sample
// Startup.cs
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
var rootDirectory1 = new DirectoryInfo("..\\storages\\storage1\\");
app.UseFileServerPlus("Server1", rootDirectory1, "/storage1", enableDirectoryBrowsing: true);
...
}
3.2 Use configure from json file
// appsettings.json
{
"FileServers": [
{
"ServerId": "Server1",
"RootDirectory": "..\\storages\\storage1\\",
"RequestPath": "/storage1",
"EnableDirectoryBrowsing": false
}
]
}
// Startup.cs
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
var configurationSection = Configuration.GetSection("FileServers");
app.UseFileServerPlus(configurationSection);
...
}
Options
1. Tag Helper
- asp-file-server-version
<img class="d-block m-auto" src="~/cat.jpg" asp-file-server-version="true" width="200" alt="Sample cat" />
2. IUrlHelper
- Url.FileServerContent("PATH")
<img class="d-block m-auto" src="@Url.FileServerContent("~/cat.jpg")" width="200" alt="Sample cat" />
3. File server context
- Get
- GetUrl
- GetWorkingDirectory
// HomeController.cs
public class HomeController : Controller
{
public IActionResult Index()
{
var fileInfo1 = _fileServerPlusContext.Get(@"/cat.jpg");
var fileInfo2 = _fileServerPlusContext.Get(@"~/cat.jpg");
var fileUrl = _fileServerPlusContext.GetUrl(@"/cat.jpg");
var directory = _fileServerPlusContext.GetWorkingDirectory();
return View();
}
private readonly IFileServerPlusContext _fileServerPlusContext;
public HomeController(IFileServerPlusContext fileServerPlusContext)
{
_fileServerPlusContext = fileServerPlusContext;
}
}
Multi File server
// appsettings.json
{
"FileServers": [
{
"ServerId": "Server1",
"RootDirectory": "..\\storages\\storage1\\",
"RequestPath": "/storage1",
"EnableDirectoryBrowsing": false
},
{
"ServerId": "Server2",
"RootDirectory": "..\\storages\\storage2\\",
"RequestPath": "/storage2",
"EnableDirectoryBrowsing": false
}
]
}
Selecte sever
- asp-file-server-id
<img class="d-block m-auto" src="~/cat.jpg" asp-file-server-id="Server1" asp-file-server-version="true" width="200" alt="Sample cat" />
<img class="d-block m-auto" src="@Url.FileServerContent("Server1","~/cat.jpg")" width="200" alt="Sample cat" />
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- Microsoft.AspNetCore.Hosting (>= 2.2.7)
- Microsoft.AspNetCore.Mvc.Razor (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.TagHelpers (>= 2.2.0)
- Microsoft.AspNetCore.StaticFiles (>= 2.2.0)
- Microsoft.Extensions.Configuration (>= 5.0.0)
- Microsoft.Extensions.FileProviders.Abstractions (>= 5.0.0)
- Microsoft.Extensions.FileProviders.Physical (>= 5.0.0)
- System.Security.Cryptography.Algorithms (>= 4.3.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.