AspNetCore-RefuseStealingMiddleWare
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace AspNetCore31.PracticalDemo.Utility.Middleware
{
public class RefuseStealingMiddleWare
{
private readonly RequestDelegate _next;
public RefuseStealingMiddleWare(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext context)
{
string url = context.Request.Path.Value;
if (!url.Contains(".jpg"))
{
await _next(context);//走正常流程
}
string urlReferrer = context.Request.Headers["Referer"];
if (string.IsNullO