0

I'm trying to create this route:

http://localhost:28790/Admin/Reporting/Reporting?reportName=MyReportName

In order to access to this Controller:

public ActionResult Reporting(string reportName){...}

For this, i've added this routing in the area:

context.MapRoute(
                "Admin_Reporting",
                "Admin/Reporting/Reporting/{reportName}",
                new
                {
                    reportName = UrlParameter.Optional
                }
            );

And I've tested this ActionLink

@Html.ActionLink(My Link, "Reporting", "Reporting", new { area = "Admin", reportName = "reportingName" })

But indeed the result is not what I expect to have:

http://localhost:28790/Admin/Reporting/Reporting?Length=9

What can I do in order to have the right URL (first URL of the post) instread of this wrong URL (latest URL of the post) ?

Thanks in advance for your help

2
  • Your using the wrong overload. It needs to be @Html.ActionLink(My Link, "Reporting", "Reporting", new { area = "Admin", reportName = "reportingName" }, null) (the null is the html attributes) Commented Mar 9, 2015 at 8:45
  • Arghhh I knew I forget something! Thanks man! Put that in answer and I'll validate it! Commented Mar 9, 2015 at 8:55

1 Answer 1

2

You using the wrong overload of @Html.ActionLink(). You need to use this overload when you specify null for the html attributes (the last parameter)

@Html.ActionLink("My Link", "Reporting", "Reporting", new { area = "Admin", reportName = "reportingName" }, null)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.