asp.net mvc 4 - HTML.ActionLink querystring param not passed to method -
examining code, don't see why fails. primary controller's index method looks this:
public actionresult index(int appeventid = -1)
there isn't querystring param, there's need route main page , pass particular id auto-display. default value of -1 indicates should display normally. works fine normally.
in page, razor code generates valid hyperlink:
@html.actionlink("back main", "index", "maincontroller", new { appeventid = -9 }, new { }) // things renamed protect innocent!
when testing locally works charm. controller index method detects -9 particular value , specific case.
however, when deployed on web server, application in subfolder, not root. works fine, in above case, generates url this:
http://server/appsubfolder/?appeventid=-9
and above url looks correct, controller's index method not passed -9.
is there limitation mvc app cannot deployed subfolder? i'm not 1 decided deploy way, i'm trying make sense of error.
well, still think bug mvc, or @ least should clearer it's not best practice set site way.
but, may interested, worked around problem replacing @html.actionlink following:
<a href='@url.content("~/controller/index?appeventid=-9")'>back main</a>
this avoids shortening /controller/method style of url "/" when it's main controller's index method, , querystring parsed correctly , passed index() method.
Comments
Post a Comment