Skip to content

Static files and matching #4215

Closed
Closed
@JamesNK

Description

@JamesNK

I updated a sample to use static files + endpoints + authz. To achieve the desired result I had to write a DIY static file endpoint matcher and it got me thinking.

RANDOM THOUGHT 1

We could add configurable static file matching to UseEndpointRouting. It would be useful when you want to run the file through APIs that use endpoints, e.g. AuthorizationMiddleware. There could be a couple of modes for matching:

  • The static files all live as endpoints provided by an endpoint datasource. High memory, long startup time, high perf
  • Or the endpoint for a static file is created on demand. Low memory, short startup time, low perf. This is what the authz sample is doing.
app.UseEndpointRouting(routes =>
{
    routes.MapApplication();
    routes.MapStaticFiles();
});

RANDOM THOUGHT 2

UseStaticFiles today is terminal if there is a matching file. If static files have endpoints then it could disappear from 3.0 templates and the static file could be returned at the end of the request pipeline.

Would there be performance considerations from doing this? It would mean static files experience the entire request pipeline, e.g. if authentication is enabled then static file requests would be authenticated.

Alternatively UseStaticFiles could remain present in templates, and if the request was matched to a static file endpoint in UseEndpointRouting then UseStaticFiles would do nothing more than invoke the endpoint and exit.

Metadata

Metadata

Assignees

Labels

Needs: DesignThis issue requires design work before implementating.area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing one

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions