Is it possible to add some middleware routes that will, for example, allow or redirect a user to access the admin panel, which if not authenticated will be redirected to the login area? as in the example below (In PHP / Laravel):
Route::get('/login', [
'as' => 'login',
'uses' => 'Auth\LoginController@Index',
'middleware' => ['guest', 'throttle:12,1'],
]);
My routes in ASP.NET:
routes.MapRoute(
name: "Admin.Login", url: "admin/login",
defaults: new { controller = "Authentication", action = "Index" },
namespaces: new[] { "Controllers.Admin.Authentication" }
);
routes.MapRoute(
name: "Admin.Login.Attempt", url: "admin/login/attempt",
defaults: new { controller = "Authentication", action = "Attempt" },
namespaces: new[] { "Controllers.Admin.Authentication" }
);
Note: my question is about routes in ASP.NET, the PHP code break is just to exemplify my question.