T4MVC @Url.Action(MVC.Controller.Action()) Renders "?Area=" Parameter in QueryString

Viewed 5422

I am rendering a menu from a Partial Action directly to the layout, using:

@Html.Action(MVC.Menu.Index())

This action, determines which Menu partial to render. For instance, a public menu partial. Within these partials, I am also using T4MVC to render the links:

<ul id="navHolder">
<li class="level1">
    <ul class="mainMenu">
        <li><b>@Html.ActionLink("Welcome", MVC.Home.Index())</b>
           ... 

For some reason, the Urls rendered by T4MVC include "?Area=" at the end:

 <ul id="navHolder">
    <li class="level1">
        <ul class="mainMenu">
            <li><b><a href="/home/index?Area=">Welcome</a></b>
               ...

I have NO areas in my project and I have turned the "IncludeAreasToken" setting to false. Oddly, this only happens if I render the partial using "@Html.Action" -- if I pull it in as "@Html.Partial" the parameter isn't rendered and the link is clean and correct. (I don't want to render it as a partial though, so please don't offer that as a suggestion ;)

Anyone out there run into this before?

3 Answers

Copied from workitem 7154 comments is a solution provided by @DavidEbbo:

A simpler workaround is to add a bogus area to your site. e.g.\n\n- Right click Project and choose Add / Area. Name it 'Dummy' (or whatever)\n- You can delete everything in there except for the DummyAreaRegistration.cs file

Make sure you have the AreaRegistration.RegisterAllAreas(); call in your Global.asax

This also works with attribute routing in place.

Related