Endpoints 404 with Asp.net MVC 5
See original GitHub issueI’m trying to get OpenIddict running with Asp.Net 4.8 and MVC 5.
I first followed the OWIN example at https://kevinchalet.com/2020/03/03/adding-openiddict-3-0-to-an-owin-application/. I am using the the recommended AutoFac registration method.
I was able to get this working properly. The tutorial says that the same should apply for other hosts, including System.Web.
However, I cannot get through to the token endpoint (or authorization endpoint if I try to add that). It always returns a 404.
So far I’ve tried
- Ignoring the endpoint routes in the MVC route config
- Adding Autofac.Mvc5 and Autofac.Mvc5.Owin
- adding calls to
app.UseAutofacMvc();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
andbuilder.RegisterControllers(typeof(MvcApplication).Assembly);
- adding calls to
- Adding a test route
app.Map('/test', b => b.Run(ctx => ctx.Response.WriteAsync("hello"));
- This also cannot be reached
My suspicion is that this is a routing issue, but I just can’t seem to find the right lead to figure it out.
Are there any special requirements for using OpenIddict with MVC 5?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Getting 404 error while calling Web API 2 from MVC 5 ...
The issue has been solved. It was due to missing WebApiConfig.cs file in App_Start folder. I have manually added the file.
Read more >why is 404 happened when i request action in a web API ...
Are you sure a 404 is returned and not a 401? Maybe the 404 is due to submitting a post but a post...
Read more >How to handle 404 errors in ASP.NET Core MVC
A simple solution is to check for the HTTP status code 404 in the response. If found, you can redirect the control to...
Read more >Controller endpoints all return 404 status code after ...
Controller endpoints all return 404 status code after upgrading to latest version of Microsoft.AspNetCore.Mvc.Versioning #448.
Read more >How to troubleshoot "HTTP ERROR 404" with ASP. ...
1. First, check if you have uploaded all necessary files of your API site to the server. · 2. Second, if the publish...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good point. I was working in a new MVC 5 project straight from the template, but I forgot to change the identity option from ‘none’ to individual accounts.
This means that the project doesn’t come with Microsoft.Owin.Host.SystemWeb out of the box. It also doesn’t install that library when you install the other requisite Owin packages or if you choose to add an Owin startup file through the ‘add new’ menu.
Installing Microsoft.Owin.Host.SystemWeb fixed the issue
Ah. I figured it should be possible to get the Authentication context off of the event context. I first looked for it on Principle, got as far as
context.Transaction.GetOwinRequest()
, and got tripped up at Context. This is definitely a nicer solution.HandleResponse()
does work. I just misinterpreted the description thinking that it would prevent my login flow from taking over. It doesn’t because the challenge writes a response rather than some internal call or middleware.I was trying to avoid the pass through option, since I’m working with two company-owned sites that will always have an implicit grant. It’s good to see that option laid out clearly out though.