Frage

I have the following ActionLink that sits in the home page on the register controller (Index.cshtml)

@Html.ActionLink("terms of service", Url.Action(MVC.Home.Terms()), 
                 null, new  { target="_blank" })

Generating the following URL. Why is "register" being added to it? It's as if the link within the Register page which has it's own controller is preappending the register controller to any link in that view?

http://localhost/register/terms-of-service

    routes.MapRoute(
        "Terms",
        "terms-of-service",
        new { controller = "Home", action = "Terms" }
    );

public partial class HomeController : SiteController
{
    public virtual ActionResult Terms()
    {
        return View(new SiteViewModel());
    }
War es hilfreich?

Lösung

Can you try generating the same link using standard MVC instead of T4MVC, to check whether the behavior is T4MVC specific? MVC behavior with routing can often be puzzling, so it's always good to isolate this first before investigating it as T4MVC thing.

Andere Tipps

This worked for me... Downloading from a .cshtml file without a redirect, etc... Took a while to get the something that worked

<a href="@Url.Action("ExportAsCSV", "Download", new { target = "_blank" })" >Download2</a> 
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top