How to get the second argument from HTTP Context? For example
localhost:45423/?login=login1/?password=password1
public class CheckData
{
private readonly RequestDelegate _next;
public CheckData(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
var login = context.Request.Query["login"];
var password = context.Request.Query["password"];
if(login != "log1" && password != "pass1")
{
context.Response.StatusCode = 403;
await context.Response.WriteAsync("Sorry, you're not logged");
}
else
{
await _next.Invoke(context);
}
}
}
PS: I've began learning ASP.NET Core today, only login works, but not login with password
You are passing the query parameters wrongly, For multiple query parameter you should pass like localhost:45423?login=login1&password=password1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.