asp.net mvc 3 - C# MVC 3 Generates Link With Unnecessary Parameters -


i'm new .net. i'm close end of first project, , i've run trivial issue that's bothering me. i'm using mvc 3, razor, c#, , visualstudio 2010.

the following razor code have redirecting user different rdlc reports:

@html.actionlink("length of stay data packages - summary", "rptlngthstay", "reports", new { @class = "link" })<br /> @html.actionlink("packages denied registration whs reviewers", "rptpkgsdenied", "reports", new { @class = "link" })<br /> <...> 

it generates following html:

<a class="link" href="/reg_pkgs/reports/rptlngthstay?length=7">length of stay data packages - summary</a><br /> <a class="link" href="/reg_pkgs/reports/rptpkgsdenied?length=7">packages denied registration whs reviewers</a><br /> <...> 

my question is, parameter "length=7" coming from? none of controllers require parameter, let alone 1 named "length." doesn't affect how of code runs, seeing in address bar bothering me.

here routes in global.asax.cs file:

public static void registerroutes(routecollection routes) {     routes.ignoreroute("{resource}.axd/{*pathinfo}");     routes.maproute(         "default", // route name         "{controller}/{action}/{id}", // url parameters         new { controller = "packagetrack", action = "tracksearch", id = urlparameter.optional } // parameter defaults     ); } 

they're default routes created new project.

any appreciated.

you using wrong overload of html.actionlink has signature (htmlhelper, string, string, object, object).

where third parameter "reports" interpreted rootvalues object, , framework tries it's properties. , string "reports" has 1 property lenght equals 7.

what need overload signature (htmlhelper, string, string, string, object, object)

change code to:

@html.actionlink("link text", "rptlngthstay", "reports", null,  new { @class = "link" })<br /> @html.actionlink("link text", "rptpkgsdenied", "reports", null, new { @class = "link" })<br /> 

note nulls 4th parameter.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -