## asp.net – How to fix an & # 39; Unauthorized Error 401 & # 39 ;, even when I'm connected?

I am creating this web page in Angular with .NET as my backend. Everything worked fine, but today (suddenly) I receive unauthorized errors (401). When I delete my authorization, I receive internal errors from the server (that is, my & # 39; User.Identity.Name & # 39;) does not work. So I guess there's a problem with my JWT

I have tried to delete the authorization headers. But that gave me an internal server error (500). The only applications that work are those that do not use IdentityUser and therefore are being [AllowAnonymous]

I have no idea what the problem might be, so it's hard to show any code. But since I think the problem has something to do with my JWT, I will add some code.

Some .NET driver code

``````[Route("api/[controller]")]
[ApiController]
[Produces("application/json")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]

public class BierenController: ControllerBase
{

Public BierenController (IBierRepository bierRepository, IGebruikerRepository gebruikerRepository, IBrouwerRepository brouwerRepository)
{
_bierRepository = bierRepository;
_gebruikerRepository = gebruikerRepository;
_brouwerRepository = brouwerRepository;
}

[HttpGet]
[AllowAnonymous]

IEnumerable public GetBieren ()
{
returns _bierRepository.GetAll (). OrderBy (b => b.Naam);
}

[HttpGet("{id}")]
[AllowAnonymous]

Public action of results GetBier (int id)
{
Bier bier = _bierRepository.GetBy (id);
if (bier == null)
returns NotFound ();
back bier
}

[HttpPost]

Public IActionResult PostBier (Bier bier)
{
Brouwer brouwer = _brouwerRepository.GetBy (User.Identity.Name);
_brouwerRepository.SaveChanges ();
returns NoContent ();
}
``````

Configuration of Startup.cs

``````    public class of start
{
Public start (ICon configuration configuration)
{
Configuration = configuration;
}

Configuration of IConfiguración pública {get; }

// This method is called by the execution time. Use this method to add services to the container.
Public void ConfigureServices (services IServiceCollection)
{

options.UseSqlServer (Configuration.GetConnectionString ("BierContext")));

{
c.Title = "BabAPI";
c.Version = "v1";
c.Description = "From API to BAB";
c.DocumentProcessors.Add (new SecurityDefinitionAppender ("JWT Token", new SwaggerSecurityScheme
{
Type = SwaggerSecuritySchemeType.ApiKey,
Name = "Authorization",
Description = "Copy & Carrier & # 39; + JWT token valid in the field"}));
});
constructor.AllowAnyOrigin ()
));

servicios.configura(options =>
{

// Lock settings.
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes (5);
options.Lockout.MaxFailedAccessAttempts = 5;
options.Lockout.AllowedForNewUsers = true;

// User settings.
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
options.User.RequireUniqueEmail = true;
});

{
x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey (Encoding.UTF8.GetBytes (Configuration["Tokens:Key"])),
ValidateIssuer = false,
ValidateAudience = false,
RequireExpirationTime = true
};
});
}

// This method is called by the execution time. Use this method to configure the HTTP request pipeline.
Public void Configure (application IApplicationBuilder, IHostingEnvironment env, services IServiceProvider)
{
if (env.IsDevelopment ())
{
app.UseDeveloperExceptionPage ();
}
plus
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts ();
}
app.UseStaticFiles ();
app.UseHttpsRedirection ();
app.UseMvc ();
CreateUserRoles (services) .Wait ();
app.UseAuthentication ();
app.UseSwaggerUi3 ();
app.UseSwagger ();
app.UseCors ("AllowAllOrigins");
}
``````

Angular authentication interceptor

``````The AuthenticationInterceptor export class implements HttpInterceptor {

constructor (private authService: AuthenticationService) {}

intercept (req: HttpRequest, next: HttpHandler): Observable <HttpEvent> {
if (this.authService.token.length) {
const clonedRequest = req.clone ({
headers: req.headers.set (& # 39; Authorization & # 39 ;, Carrier \$ {this.authService.token} `)
});
return next.handle (clonedRequest);
}
returns next.handle (req);
}
}
``````

.NET Login / Register / Tokencreation

``````        [AllowAnonymous]
[HttpPost]

{
var user = awaits this._userManager.FindByNameAsync (model.GebruikersNaam);

if (user == null)
{
user = await this._userManager.FindByEmailAsync (model.GebruikersNaam);
}

yes (user! = null)
{

yes (result, successful)
{
chain token = awaits GetTokenAsync (user);
returned Created ("", token);
}
}
}

Private asynchronous task GetTokenAsync (IdentityUser user)
{
var role = awaits _userManager.GetRolesAsync (user);
IdentityOptions _options = new IdentityOptions ();
var key = new SymmetricSecurityKey (Encoding.UTF8.GetBytes (_config["Tokens:Key"]));

var tokenDescriptor = new SecurityTokenDescriptor
{
Subject = new ClaimsIdentity (new claim[] {
new complaint (_options.ClaimsIdentity.RoleClaimType, role.FirstOrDefault ())
}),

SigningCredentials = new SigningCredentials (key, SecurityAlgorithms.HmacSha256),
};
var tokenHandler = new JwtSecurityTokenHandler ();
var securityToken = tokenHandler.CreateToken (tokenDescriptor);
var token = tokenHandler.WriteToken (securityToken);
}

[AllowAnonymous]
[HttpPost("register")]

Asynchronous public task <ActionResult> Register (model RegisterDTO)
{
IdentityUser user = new IdentityUser {UserName = model.GebruikersNaam, Email = model.Email};
var result = await _userManager.CreateAsync (user, model.Password);

yes (result, successful)
{
{
Brouwer brouwer = new Brouwer {Naam = model.GebruikersNaam, Email = model.Email};
_brouwerRepository.SaveChanges ();
}
else if (model.Email.ToLower (). Equals ("brouwer1@hotmail.com"))
{
Brouwer brouwer = new Brouwer {Naam = model.GebruikersNaam, Email = model.Email};
_brouwerRepository.SaveChanges ();

}
plus
{
Gebruiker gebruiker = new Gebruiker {Email = model.Email, Gebruikersnaam = model.GebruikersNaam};
_gebruikerRepository.SaveChanges ();
}
chain token = awaits GetTokenAsync (user);
returned Created ("", token);
}
else {
}
``````

## Can not connect to the computer through the Powerline WiFi extender on the computer directly connected to the router

I am currently using a Powerline TP-Link AV600 WiFi extender to allow devices in my home office (away from the router) to connect to the Internet wirelessly (which works well).

The problem I have is that if I am connected to a computer that connects to the router's WiFi, I can not connect (ping, RDP, etc.) to computers that connect to Powerline's WiFi.

The devices are all in the same subnet:
Router (PlusNet Hub One): 192.168.1.254
Computer A (connected to the router's Wi-Fi): 192.168.1.144
Computer B (connected to Powerline WiFi): 192.168.1.148

If I move computer A to Powerline WiFi, I can connect well.

Is this just a limitation of the WiFi Powerline extensors in general, this particular model, or is it likely to be a configuration problem in my network?

## mg. metric geometry: if a metric (distance) in a locally connected Riemannian manifold is in accordance with the Riemannian metric, is it equal to the induced metric?

Leave $$(M, g)$$ be a Riemann grocery store connected.
Leave $$d_g$$ be the induced distance metric of $$g$$. Now leave $$d$$ be some other metric in $$M$$.

Suppose that for each $$x in M ​​$$, there is a neighborhood $$U$$ of $$x$$ so that $$d = d_g$$ in $$U times U$$.

Question: This implies that $$d = d_g$$ in $$M times M$$?

I am do not assuming that $$d$$ is the metric of some Riemannian metric; I know the answer is yes in that case.

Observations:

1. It is clear to me that $$d = d_g$$ in a neighborhood of the diagonal in $$M times M$$; this is essentially just a reformulation of the hypothesis.

2. The connection is necessary to avoid stupid examples of accountants. For example, we could take two disjoint points. $${x, y }$$. So $$d_g$$ between them is infinity, but we can take $$d (x, y) = 1$$. They both agree in a neighborhood of $$x$$namely $$x$$. (We can build similar examples by taking disjoint unions of non-zero-dimensional varieties).

3. Maybe the question is correct & # 39; is actually: let X be a connected topological space (route) and consider two metrics $$g$$ Y $$h$$ in X, compatible with the topology in X. If these metrics are locally equal in the sense of the question (that is, they coincide in a neighborhood of the diagonal), are they equal? (I feel that this has an obvious proof or some terrible counter example, it seems to be true in the graphs that are made by assigning edge lengths).

4. I (I think) can prove a special case. See the motivation section below.

Motivation: Leave $$(N, h)$$ be a connected Riemannian distributor, with geodetic distance function $$d_N$$. Leave $$G$$ Be the group of a coverage space action by isometries in. $$N$$, with quotient map $$pi$$, with $$G$$ finite. So $$N / G$$ inherit a Riemannian metric $$g$$ through the use of local trivializations. $$N / G$$ It also inherits a metric, defined by $$d ([x], [y]) = inf_ {g in G} d_N (gx, y)$$. In the zone $$d = d_g$$ due to local trivializations. I want to know if $$d = d_g$$ in all $$N / G$$.

I think this is true if the geodesic distance between two points any in $$N$$ Y $$N / G$$ it is always done by some shorter way, by using the coverage space, the survey + being geodesic is a local condition + isometry of coverage actions to relate the shorter paths in $$N$$ to those in $$N / G$$. I mean, yes $$g$$ minimize $$d (gx, y)$$ leave $$gamma: [0,1] a N$$ be a shorter path in $$N$$ Between $$gx$$ Y $$and$$. So $$pi ( gamma)$$ is a geodesic (potentially self-intersecting), of the same length as $$gamma$$connecting $$[x]$$ Y $$[y]$$. Thus $$d_g leq d$$. On the other hand, if we have a geodesic route. $$gamma$$ since $$[x]$$ to $$[y]$$, we can elevate it to a geodesic from $$x$$ to $$hy$$ of the same length, for some $$h in G$$, and therefore $$d_g geq d$$.

I would like to be able to abandon this condition because there are always shorter path witnesses at shorter distances (I mean that the inf is reached in the geodesic distance). I think maybe in this case of coverage space this can be achieved by taking a sequence of paths that approach the geodesic distance, but the argument begins to become much more confusing, and I am already out of my comfort zone and I am delaying my real work since it is …

I would appreciate a reference for the main question or motivation.

## Wi-Fi: the Android device uses an incorrect location when it is connected to a WiFi, the location of other devices is correct

I have a new Galaxy M10 and Xiaomi Pocophone F1.

When I connected the Galaxy M10 device to my Huawei MiFi router (I use this router for 2 years), it shows that my location is "Laos", but this is completely incorrect. I live in Sri Lanka But other devices, including Pocophone F1, Windows 10 and OnePlus 3T, are showing the correct location.

When I deactivated the Samsung Galaxy M10 WiFi and / or switched to another Wi-Fi network, it again shows the correct location. How do I correct this error?

## How to obtain the IP of the file storage connected to the Cisco 4431 router?

Hopefully this is a relevant question.

I will try to provide as much information as possible, although some of them may not be relevant, however, I do not want to lose any useful information possible.

Basically, we, company A, have a Cisco 4431 router installed in the network of company B. The router manages some servers (mainly Ubuntu and some Windows). Usually, VPN in B and ssh in one of the Ubuntu servers (U) to work in the command line environment. Now we need to add an external hard drive, to be specific, Aegis Padlock DT – USB 3.0 Desktop Unit (D)

to the router so you can back up the data from U to D. D will connect to the router through the USB portal.

My question is how can I find out the IP of D assigned by the router. What I tried so far were:

1, start Firefox in U and enter 192.168.1.1 as the address, but this could not show me the administration page of the router, but I did get an error message. I did it because I can do this in my house and get the administration page). Y

2, ssh on the router's command-line interface successfully, but I do not know what command (s) to use to see the currently used IP addresses and related information. I tried to find a tutorial but I did not find the commands.

How can I find the IP of D assigned by the Cisco 4431 router?

## macos: how to reassign the screen numbering when you have more than 2 monitors connected to mac mini

I have three screens connected to my mac mini. The most to the left is the primary one with the pier. However, the central screen is called "Screen 3" and the closest one is "Screen 2". Even if I change the cables, it remains the same, so OSX should remember the displayid. This is a problem because the space desktops are out of sequence and can not be moved across the screens. It is also a confusion when you assign an application to a screen, you must remember that 3 is the central screen. I know that only screen 2 and 3 could physically change. But this must be solved in the software. 🙂

Any suggestions on how the numbering of the screens can be reassigned?

Thank you

## Connected Android Samsung S5 How to download from the phone to the PC to the PC The Windows 10 icon may or may not show and does not recognize the inc files. Photos

#### Stack exchange network

The Stack Exchange network consists of 175 question and answer communities including Stack Overflow, the largest and most reliable online community for developers to learn, share their knowledge and develop their careers.

Visit Stack Exchange

## hardware failure: bought a new hard drive, but when it is connected to the power supply, it will not start

I bought a new 1TB barracuda hard drive, plugged it in and started it. But on the second boot with my solid state drive connected, the computer will not boot either. I checked the solid state on another computer and it still works. Now it will not start the only activity that I get is that a fan starts to turn slightly.

Am I just me connecting things wrong?

## Show that if a graph is connected to k, then it is also connected to k-edge

Here is my thought, first if it is connected to k, then each vertex has a degree at least k. Therefore, the elimination of a set of edges of size K-1 will not produce any isolated vertex. I do not know how to continue.