Comments (2)
If you're using attribute routing I suggest you inherit both controllers from a base class, and putting a routeprefix in the version implementation. Otherwise, check out the newer beta version.
from sdammann.webapi.versioning.
@Sebazzz I upgraded to the 3.0 beta as you stated.
Here is my configuration code which uses Autofac for by dependency injector:
`// Create our autofac dependency container.
ContainerBuilder builder = new ContainerBuilder();
// Add controller to our dependency container.
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
// Add items to our dependency container needed for our api versioning.
builder.Register(c => new DefaultControllerIdentificationDetector(config));
builder.Register(c => new DefaultRequestControllerIdentificationDetector(config));
// Build our dependency container and set as our dependency resolver.
IContainer container = builder.Build();
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
// Setup our routes.
config.MapHttpAttributeRoutes();
// Set our url based api versioning.
ApiVersioning.Configure(config)
.ConfigureRequestVersionDetector<DefaultRouteKeyVersionDetector>();`
Again my controller configuration is as follows:
Controllers
-Version1
--AccountController.cs
-Version2
--AccountController.cs (Inherits from Version1 controller)
An example of a route attribute I placed on the version 1 controller:
[Route("v{version}/account/login")]
When I request this route using Postman I get a 404 error.
Can you confirm this setup should be supported using the beta version and if so what configuration changes do you recommend to pull it off?
Also what lifetime scope should be applied to the two items added to the dependency injector:
DefaultControllerIdentificationDetector
DefaultRequestControllerIdentificationDetector
Thank you in advance for any help you can provide.
Take care,
Ken
from sdammann.webapi.versioning.
Related Issues (20)
- Is .net 4.5 support? HOT 3
- Incorrect NuGet dependencies? HOT 2
- ArgumentException with VersionedApiExplorer HOT 5
- Routing issue HOT 5
- DLL Depends on System.Web.Http 5.1.0.0 HOT 3
- Multiple actions were found that match the request HOT 2
- Ability to change version header name in VersionHeaderVersionedControllerSelector HOT 3
- Attribute routing HOT 6
- Exception handling HOT 2
- Configurable error messages HOT 3
- ArgumentNullException when version header missing
- Ambiguous routes reported incorrectly HOT 6
- beta3 throws null exception, where beta1 wasn't HOT 1
- MvcApplication3.Areas.HelpPage.XmlDocumentationProvider' does not implement interface member 'System.Web.Http.Description.IDocumentationProvider.GetResponseDocumentation
- Inherting from VersionedApiControllerSelector HOT 7
- Use both URL & HTTP Header versioning at the same time HOT 1
- Use SDammann.WepApi.Versioning with swagger HOT 5
- Integrating Versioning in an already in production API HOT 1
- [HttpRoute] Multiple controllers defined with the same name but differing namespaces HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdammann.webapi.versioning.