Request matched endpoint 405 HTTP Method Not Supported

Carl-Johan Uhlin 1 Reputation point
2021-12-04T09:37:53.003+00:00

0

This sound simple I just change from post to get but the do not help. I am trying to make a login against ADF2016 and when I am getting redirected back, I get this error in my backend. Now I have tried all changes I can think of so it time ask a question here with hope of a resolution.

The trace log leading up the exception:

x=Microsoft.AspNetCore
x.Authentication.Cookies.CookieAuthenticationHandler: AuthenticationScheme: Identity.External signed in.
x.Hosting.Diagnostics: Request finished HTTP/1.1 POST https://.../backend/adfscallback application/x-www-form-urlencoded 5316 - 302 - - 318.8660ms
x.Hosting.Diagnostics: Request starting HTTP/1.1 GET https://.../backend/adfscallback - -
x.HostFiltering.HostFilteringMiddleware: All hosts are allowed.
x.DataProtection.KeyManagement.KeyRingBasedDataProtector: Performing protect operation to key {53f014ae-56d8-44e9-b9c8-d5f9b04ec57d} with purposes ('C:\home\site\wwwroot\frontend\backend', 'SessionMiddleware').
x.Routing.Matching.DfaMatcher: 1 candidate(s) found for the request path '/adfscallback'
x.Routing.EndpointRoutingMiddleware: Request matched endpoint '405 HTTP Method Not Supported'
x.Authentication.WsFederation.WsFederationHandler: Error from RemoteAuthentication: No message..
x.Diagnostics.DeveloperExceptionPageMiddleware: An unhandled exception has occurred while executing the request.
System.Exception: An error was encountered while handling the remote login.
 ---> System.Exception: No message.
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.HandleRequestAsync()
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext c

The declaration for function I try to call:

[HttpPost]        
public async Task<ContentResult> CallbackAsync(string returnUrl = null, string remoteError 

My startup.cs

public void ConfigureServices(IServiceCollection services)
{
     String connectionString = GetSqlServerConnectionString();
     services.AddSession();

     services.AddDbContext<ApplicationDbContext>(options =>
           options.UseSqlServer(connectionString));

     services.AddIdentity<IdentityUser, IdentityRole>()
          .AddEntityFrameworkStores<ApplicationDbContext>();


     services.AddAuthentication()
          .AddWsFederation(options =>
     {
          options.MetadataAddress = "https://.../FederationMetadata.xml";

          options.Wtrealm = "....";

           options.Wreply = "https://.../backend/adfscallback";

          options.CallbackPath = new PathString("/adfscallback");

     });

     services.AddControllersWithViews();            
     }


public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseExceptionHandler("/Home/Error");
        app.UseHsts();
    }

    app.UseHttpsRedirection();
    app.UseSession();
    app.UseRouting();

    app.UseAuthentication();
    app.UseAuthorization();

    app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllerRoute(
                name: "default",
                pattern: "{controller=Home}/{action=Index}/{id?}");
    });
}
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,161 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,254 questions
Active Directory Federation Services
Active Directory Federation Services
An Active Directory technology that provides single-sign-on functionality by securely sharing digital identity and entitlement rights across security and enterprise boundaries.
1,189 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,238 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
294 questions
{count} votes