© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
barcode

Static files asp.net

Hello, in my app I have 2 middlewares that are ran before any request but I want to disable them for static files. These middlewares check for a token but i don't want to force the user to be authorized to access some images.

app.UseStaticFiles();
app.UseMiddleware<AuthMiddleware>();
app.UseMiddleware<AccessMiddleware>();
app.UseStaticFiles();
app.UseMiddleware<AuthMiddleware>();
app.UseMiddleware<AccessMiddleware>();


I can't find anything on documentation nor google how to do this. What is the correct way?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Asp.net (.net461, global.asax)
C#CC# / help
15mo ago
✅ ASP.NET files not downloading properly
C#CC# / help
7mo ago
❔ ASP.NET Core reroute requests for static files to a different server
C#CC# / help
4y ago
❔ How to fix the issue with the referencing static files in ASP.NET core
C#CC# / help
4y ago