Skip to content
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

Add a notice about AttributeRouting integration into ASP.NET MVC 5 #272

Open
leniel opened this issue Oct 2, 2013 · 13 comments
Open

Add a notice about AttributeRouting integration into ASP.NET MVC 5 #272

leniel opened this issue Oct 2, 2013 · 13 comments

Comments

@leniel
Copy link

leniel commented Oct 2, 2013

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:

 routes.MapAttributeRoutes(config =>
            {
                config.AddRoutesFromAssembly(Assembly.GetExecutingAssembly());
                config.UseLowercaseRoutes = true;
                config.PreserveCaseForUrlParameters = true;
            });
@stevenao
Copy link

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.

@DavidBoike
Copy link
Contributor

+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.

@mdmoura
Copy link

mdmoura commented Oct 24, 2013

Same problem here ... I was using AR in many projects and now I am having problems:

  1. Web API does not have RouteArea anymore?

    [RouteArea("CMS", AreaUrl = "{culture}/CMS"), RoutePrefix("Api/Access")]
    public class UserController : ApiController { }

  2. Custom configuration with the advanced options is not available?

    RouteTable.Routes.MapAttributeRoutes(x => {
    x.AddRoutesFromAssemblyOf();
    x.AddTranslationProvider();
    x.ConstrainTranslatedRoutesByCurrentUICulture = true;
    x.AddDefaultRouteConstraint // ...
    }

  3. And FluentTranslationProvider is not available also ...

  4. AreaUrl not available in MVC controllers?

    [RouteArea("CMS", AreaUrl = "{culture}/CMS")]
    public partial class UserController : WebController { }

  5. On the views @Html.HttpMethodOverride is not available anymore?

  6. Route.axd and GET/POST are also missing and they were really nice.

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

@mccalltd
Copy link
Owner

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. :(

@mdmoura
Copy link

mdmoura commented Oct 24, 2013

That is bad news ...

Do you think it would be possible, in MVC5, to plug a TranslationProvider?

@stevenao
Copy link

https://github.com/ASP-NET-MVC/aspnetwebstack/blob/master/src/System.Web.Mvc/Routing/AttributeRoutingMapper.cs

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.

@stevenao
Copy link

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...

@mdmoura
Copy link

mdmoura commented Oct 26, 2013

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.

@stevenao
Copy link

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.

@di97mni
Copy link

di97mni commented Nov 18, 2013

@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?

@di97mni
Copy link

di97mni commented Nov 19, 2013

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!

@stevenao
Copy link

@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.

@di97mni
Copy link

di97mni commented Nov 21, 2013

Setting target to 4.5.1 helped

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

No branches or pull requests

6 participants