Matt V
Matt V

Reputation: 1

T4MVC causing incorrect URL's

Using T4MVC on my new MVC Razor Project and I will have an action link like so

@Html.ActionLink(ViewRes.SharedStrings.HomeLink, MVC.Home.Views.Index, null, new { rel = "dropmenu7" })

so i would expect a url like http://localhost:52122/Home/Index

but what i am getting is http://localhost:52122/Home/~/Views/Home/Index.cshtml

looking into the t4mvc template file, i see where the "~/Views/Home/Index.cshtml" is coming from but I dont wanna touch it because it was made that way and i would guess i shouldnt have to change anything there.

Asking a friend, he says that i should use RouteLink instead of ActionLink because i am sometimes going to locations outside of the controller. However when i do that, i get: "A route named '~/Views/Home/Index.cshtml' could not be found in the route collection." when i try to run the app.

I guess i should also note that the links i am using are in the _Layout.cshtml

What am i doing wrong?

Upvotes: 0

Views: 336

Answers (1)

David Ebbo
David Ebbo

Reputation: 43183

You need to change 'MVC.Home.Views.Index' to 'MVC.Home.Index()':

@Html.ActionLink(ViewRes.SharedStrings.HomeLink, MVC.Home.Index(), null, new { rel = "dropmenu7" })

Upvotes: 2

Related Questions