Request matched endpoint 405 HTTP Method Not Supported
Carl-Johan Uhlin
1
Reputation point
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?}");
});
}
Sign in to answer