Skip to content

Startup.cs in another assembly causes OData to return 404. #551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joshmackey opened this issue Oct 2, 2019 · 5 comments
Closed

Startup.cs in another assembly causes OData to return 404. #551

joshmackey opened this issue Oct 2, 2019 · 5 comments

Comments

@joshmackey
Copy link

Still tracing down exactly what's happening, but I have a simple ASP.Net Core Startup class that configures OData with api versioning.

If I run the Startup class in the entry dotnet core assembly, everything works as it should, however, if the Startup class is in a separate assembly, all odata related routes start returning 404 (including the $metadata endpoint).

Trace logging shows that the route is being matched, but no matching actions are found.

Will update as I come across more information.

@joshmackey
Copy link
Author

I don't know if it's related or not, but the OData endpoints start returning 404 the moment I call AddApiVersioning(). Seems like the replaced IActionSelector can't find them anymore?

@joshmackey
Copy link
Author

joshmackey commented Oct 2, 2019

It's the following code:

var applicationPartManager = app.ApplicationServices.GetRequiredService<ApplicationPartManager>();
applicationPartManager.ApplicationParts.Add(new AssemblyPart(typeof(VersionedMetadataController).Assembly));

For unknown reasons, it's adding the wrong assembly to the ApplicationPartManager. If I run that code in my Startup class directly, the correct assembly gets added.

@commonsensesoftware
Copy link
Collaborator

ASP.NET Core usually needs some help in this type of scenario. This would especially be true if all of the OData configuration is external too. It sounds as though that might be the case since you mentioned that you need to add the VersionedMetadataController.

Were you able to get things working? It sounds like you did. Let me know if there's anything else required to resolve this issue.

Thanks.

@joshmackey
Copy link
Author

I worked around it, but it's still an issue to be fixed. typeof(VersionedMetadataController).Assembly should have fetched the correct assembly, but it didn't.

@commonsensesoftware commonsensesoftware added this to the 4.0.1 milestone Oct 30, 2019
@commonsensesoftware
Copy link
Collaborator

This is pretty easy to workaround, but I'm tracking this for a future release. In the next patch, I believe this can be fixed. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants