Konteks
VS 2019, .NET Core 3 Pratinjau 5. Saya telah membuat Aplikasi Web ASP MVC yang baru. Sekarang periksa kode StartUp:
// ...
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
//...
Ketika saya mencoba melihat apa yang dilakukan metode ekstensi tersebut, saya pergi ke sumbernya (dalam kasus saya ctrl+klik dan itu memanggil dekompiler JetBrain) saya mendapatkan ini:
// Decompiled with JetBrains decompiler
// Type: Microsoft.AspNetCore.Builder.AuthAppBuilderExtensions
// Assembly: Microsoft.AspNetCore.Authentication, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
// MVID: A1CE531C-37CE-4C8A-B143-24C2AC9CFE19
// Assembly location: C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\3.0.0-preview5-19227-01\ref\netcoreapp3.0\Microsoft.AspNetCore.Authentication.dll
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Extension methods to add authentication capabilities to an HTTP application pipeline.
/// </summary>
public static class AuthAppBuilderExtensions
{
/// <summary>
/// Adds the <see cref="T:Microsoft.AspNetCore.Authentication.AuthenticationMiddleware" /> to the specified <see cref="T:Microsoft.AspNetCore.Builder.IApplicationBuilder" />, which enables authentication capabilities.
/// </summary>
/// <param name="app">The <see cref="T:Microsoft.AspNetCore.Builder.IApplicationBuilder" /> to add the middleware to.</param>
/// <returns>A reference to this instance after the operation has completed.</returns>
public static IApplicationBuilder UseAuthentication(
this IApplicationBuilder app)
{
throw null;
}
}
}
Pertanyaan
Saat saya men-debug kode, saya tidak mendapatkan Exception
jadi sepertinya kode tersebut tidak berjalan. Kesimpulan saya, bahwa apa yang dirujuk oleh proyek itu adalah rakitan kosong tiruan, (lihat baris komentar // Assembly location: C:\Program Files...
di sumber yang telah didekompilasi) tetapi saya tidak mengerti mekanisme mengapa runtime rakitan lain akan dimuat?
Adakah yang bisa menjelaskan apa yang sebenarnya terjadi di sini?
Microsoft.AspNetCore.Authentication.dll
di direktori bin Anda. - person CodeCaster   schedule 08.05.2019ref
dll, tetapisrc
dll? - person Legends   schedule 01.10.2019