ASP.NET Core

ASP.NET Core

ASP.NET Core is a cross-platform, high-performance, open-source framework for building modern, cloud-enabled, internet-connected apps.

...see more

Kubernetes ist in der Cloud-Welt allgegenwärtig; nahezu alle Public-Cloud-Anbieter offerieren Kubernetes als Managed Service oder nutzen es intern für ihre PaaS- und Serverless-Dienste. Auch in lokalen Rechenzentren wird Kubernetes häufig eingesetzt und entfaltet dort seine Stärken als Plattform. Obwohl sich die verschiedenen Kubernetes-Distributionen und Managed Services in technischen Details wie Installation und Integration von Netzwerk- und Speicherressourcen unterscheiden, bleibt die Plattform für Anwendungen weitgehend einheitlich. Mit minimalen Konfigurationsanpassungen können Applikationen sowohl in der Cloud als auch in On-Premises-Umgebungen nahtlos betrieben werden.

Quelle: Kurs auf Kubernetes! (dotnetpro.de)

...see more

Inject Configuration

To inject configuration settings in your ASP.NET Core application, use Microsoft.Extensions.Configuration and inject IConfiguration into your page or component. Access configuration values using Configuration["KeyName"].

@using Microsoft.Extensions.Configuration
@inject IConfiguration Configuration

<!-- Access configuration value -->
@Configuration["ApplicationInsights:InstrumentationKey"]

Options Pattern

For more structured configuration management, use the options pattern with Microsoft.Extensions.Options. Inject IOptionsMonitor<TOptions> with @inject and access configuration values through OptionsAccessor.Value.PropertyName.

@using Microsoft.Extensions.Options
@inject IOptionsMonitor<ApplicationInsightsOptions> ApplicationInsightsOptionsAccessor

<!-- Access configuration value -->
var instrumentationKey = ApplicationInsightsOptionsAccessor.Value.InstrumentationKey;

For detailed information, refer to the ASP.NET Core documentation on configuration options.

...see more

Razor is a concise markup language that integrates server-side code (C# or VB) into ASP.NET web pages seamlessly. It simplifies web development by blending code and HTML, enhancing productivity and maintainability.

@page
@model IndexModel
@{
    ViewData["Title"] = "Home page";
}
<h1>@ViewData["Title"]</h1>
<p>Welcome to my ASP.NET Core Razor Pages!</p>

In this code snippet, the @page directive specifies the page, @model defines the page's model, and @ViewData displays dynamic data within the Razor Page markup.

Resources

...see more

Razor Syntax allows you to embed code (C#) into page views through the use of a few keywords, and then have the C# code be processed and converted at runtime to HTML.

...see more

Here are six different ways to run your ASP.NET Core web application:

  1. Visual Studio F5: Simply press F5 in Visual Studio to run your application.
  2. Command Line (dotnet run): Open a terminal and run dotnet run in your project directory.
  3. Publish and Run: Use dotnet publish to create a publish folder, then navigate to bin\{...}\publish and run dotnet YourProject.dll.
  4. IIS: Host your application on IIS for production-level hosting.
  5. Linux Console: Run dotnet YourProject.dll on Linux from the console.
  6. Linux with Supervisor and Nginx: For robust production setups on Linux, use Supervisor to manage your application and Nginx as a reverse proxy.

For more detailed information, check out the guide on 6 different ways to run an asp.net core web application (secretGeek.net)

...see more

Before jumping to the solution, let's talk about use cases. Using both tokens and cookies is not a common use case, but it typically comes up when you have a SPA or pure API applications that also need to secure some non-SPA pure Web Browser end points that the server sends directly to the browser. If that content needs to be protected behind authentication you might need Cookie authentication, because you can't do Bearer Token authentication with plain HTML interfaces in the browser.

services.AddAuthentication(options =>
    {
        // custom scheme defined in .AddPolicyScheme() below
        options.DefaultScheme = "JWT_OR_COOKIE";
        options.DefaultChallengeScheme = "JWT_OR_COOKIE";
    })
    .AddCookie("Cookies", options =>
    {
        options.LoginPath = "/login";
        options.ExpireTimeSpan = TimeSpan.FromDays(1);
    })
    .AddJwtBearer("Bearer", options =>
    {
        options.TokenValidationParameters = new TokenValidationParameters
        {
            ValidateIssuer = true,
            ValidIssuer = config.JwtToken.Issuer,
            ValidateAudience = true,
            ValidAudience = config.JwtToken.Audience,
            ValidateIssuerSigningKey = true,
            IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(config.JwtToken.SigningKey))
        };
    })

Source: Combining Bearer Token and Cookie Authentication in ASP.NET - Rick Strahl's Web Log (west-wind.com)

Add to Set
  • .NET
  • Agile
  • AI
  • ASP.NET Core
  • Azure
  • C#
  • Cloud Computing
  • CSS
  • EF Core
  • HTML
  • JavaScript
  • Microsoft Entra
  • PowerShell
  • Quotes
  • React
  • Security
  • Software Development
  • SQL References
  • Technologies
  • Testing
  • Visual Studio
  • Windows
 
Sets