cdub
cdub

Reputation: 25741

Url.Action not routing correctly in .NET Hybrid MVC/Web Forms app

I have a file structure like so:

/Areas/ProjectApp/Controllers/
/Areas/ProjectApp/Models/
/Areas/ProjectApp/Views/

Inside Views folder I have a projectlist.cshtml which has a link like so:

<a href="@Url.Action("Index")">Project Home</a>

The project home is actual at:

http://localhost:57538/ProjectApp

The route though gets generated as such:

http://localhost:57538/?action=Index&controller=Home

That in turn leads it to:

http://localhost:57538/ (the home page of the bigger app)

How do I fix this? Thanks in advance.

Upvotes: 1

Views: 61

Answers (1)

Joe Wilson
Joe Wilson

Reputation: 5671

It looks like you are using areas, in which case you have to specify the area in the Url.Action.

<a href="@Url.Action("Index", "Home", new { Area = "ProjectApp" })">Project Home</a>

Upvotes: 1

Related Questions