Open leniel opened 11 years ago
I am also trying to migrate my mvc4 project using AR to mvc5 too. I have a class which extends the IAttributeRouteFactory and assign it through routes.MapAttributeRoutes(cfg => { cfg.AddRoutesFromAssembly(Assembly.GetExecutingAssembly()); cfg.AttributeRouteFactory = new MyAttributeRouteFactory(); cfg.UseLowercaseRoutes = true; }); .
I just don't see how it can be done in MVC5 stripped down version of attribute routing. Also, it is sad to see MVC5 to copy the AR stuff without giving it some acknowledgement in regarding the namespace. It also makes life a little hard if we want to roll out own Nuget AR package. They both use the RouteXXXX attributes. The problem wouldn't happen if MVC5 incorporate the full functionality of AR.
+1.
I was excited to hear that AR was being rolled into MVC 5 but the stripped down implementation is disappointing. Biggest problem seems to be figuring out how to continue to use the AR package in an MVC 5 project since that creates so many name collisions, especially without any guidance (or even acknowledgement) on the AR.net site.
Currently I really miss the GET/POST attributes and the routes.axd handler.
It would also be really great if there was an AttributeRouting.MVC5 library (or pick a different name) that added all the good advanced stuff back in on top of the MVC5-baked-in implementation.
Same problem here ... I was using AR in many projects and now I am having problems:
Web API does not have RouteArea anymore?
[RouteArea("CMS", AreaUrl = "{culture}/CMS"), RoutePrefix("Api/Access")] public class UserController : ApiController { }
Custom configuration with the advanced options is not available?
RouteTable.Routes.MapAttributeRoutes(x => {
x.AddRoutesFromAssemblyOf
AreaUrl not available in MVC controllers?
[RouteArea("CMS", AreaUrl = "{culture}/CMS")] public partial class UserController : WebController { }
Well, these were the ones I found out missing in MVC5.
I agree with David Boike. It would be really nice to have an AttributeRouting.MVC5 package.
Any idea if this would be possible in any time soon?
I do not know what to do ... Stay with MVC4 or move to MVC5.
Thank You
Hi all. I have been way out of the loop with things (work and life). I have no time to devote to AR. I'll have to get a notice out to that effect and look for new blood to maintain the project going forward.
Regarding MVC5 etc. Probably should be in a new OSS project, or a fork of this one. Again, I have to be real and admit that I just don't have the time. :(
That is bad news ...
Do you think it would be possible, in MVC5, to plug a TranslationProvider?
Take a look at the the file. It has basically a generator from attributes to route in MVC5. In MVC5, most of the core attribute route stuff is marked as internal. I spent an hour to find an extension point to it, no result. I think you can still use the AR library, but you have to specify the namespace explicitly. It is just bad idea in MVC5 to have their attribute routing in the core namespace, given that they take the idea from AR library.
using RoutePrefixAttribute = AttributeRouting.RoutePrefixAttribute; using RouteAreaAttribute = AttributeRouting.RouteAreaAttribute;
The above 2 lines should solve most of the namespace conflicts. AR routes.axd seems to be working in MVC5 fine. So, if we are to rename the AR.RouteXXXAttribute classes, what would be the suggestions? Something short and simple.
ps. I still think MVC5 should have its own namespace for their copycat attribute routing stuff, but what can we do...
I think maybe the best option would be to pick everything that is not supported in MVC5 attribute routing and create a package AttributteRouting.MVC5.
As far as I found out this would be: RouteArea (Web API), Localization, AreaUrl, Fluent Configuration and Routes.axd,
I have been looking at the localization part ... On that part everything seems ok.
Does it make sense to have constratins, RoutePrefix and so on duplicated MVC 5 and AR?
That is why I think having a different package would be better.
well, I did some initial work to make compatible with MVC5. All tests ran okay and that was about it. I didn't do extensive test on it. Feel free to check out my fork under mvc5 branch.
@stevenao I can't get your commit to work. I upgraded my solution with your AR dll's but when I build my solution it complains about not finding AttributeRouting. Very strange. R# finds it.
The type or namespace name 'AttributeRouting' could not be found (are you missing a using directive or an assembly reference?)
Any ideas?
Have anyone got AR to work with Web API 2? I tried @stevenao commit but it complains with above error. What worries me is that Web API 2 lacks some features, one is for example that it looks like it can't be run in self host, and that this project has no owner anymore!
@di97mni: I am not sure what constitutes to your compilation issues. I assume you compiled the clone's mvc5 branch successfully and you are grabbing the generated AR library dll to use in your project. Is your project referencing .Net 4.5.1? You should pay attention to the projects in the test folder. They two are a SelfHost and Web sample. I ran them they both run okay.
@di97mni: I believe you need to run the AttributeRouting.Tests.SelfHost project in Visual Studio Admin mode. I recall I needed to do so to start it.
On the side note, there are some test cases don't pass. They need to be updated accordingly. I did some with the flowspec test cases and left out the rest until I find time again to do them. Also, the nuget version and publishing tag need to be updated when I am not too familiar with publishing in Nuget.
Setting target to 4.5.1 helped
The title says it all...
A notice on the front page here on GitHub and at http://attributerouting.net/ to inform that AttributeRouting is being integrated into ASP.NET MVC 5. This would help a lot!
I'm upgrading a project and testing ASP.NET MVC 5 and got a lot of conflicts during build. I had to remove the NuGet package and change
[GET] [POST]
to[HttpGet] [HttpPost]
.By the way: how's the integration going? Are all the features existent in AttributeRoting going to be incorporated into the WebStack like the configuration options: