Jacques
Jacques

Reputation: 7135

MVC Html.ActionLink renders Area as QueryString instead of as part of the URL

The following line in one project:

@Html.ActionLink("Today's Specials", "Specials", "Shop", new {area = "Books" } , null)

Correctly renders the following link URL:

http://example.com/Books/Shop/Specials

But in another visual studio application the exact same link renders the following incorrect link URL:

http://example.com/Shop/Specials?area=Books

Both apps use .net 4.5, however the second app where it doesn't work uses a slightly newer version of System.Web.MVC (5.2.30128.0 vs. 5.0.11001.0) and System.Web.Razor (3.0.30128.0 vs. 3.0.11001.0).

What am I missing here?

Upvotes: 0

Views: 141

Answers (1)

Andrei
Andrei

Reputation: 44600

I suspect, you have it because in one of the projects you don't have call in Global.asax:

AreaRegistration.RegisterAllAreas();

It also may depend on your routes.

Upvotes: 1

Related Questions