c# - Asp.net mvc won't take the razor parameter -


i'm developing on school project has gone great far problem has arrived.

i have method in homecontroller:

    [httppost]     public actionresult getseatsinshow(int showid)     {         ...         return view(realseatlist);     } 

in view use razor parse parameter controller , controller should return result in address this:

http://localhost:1499/home/getseatsinshow/236 

that if on other controller method called shows on following url:

http://localhost:1499/home/shows/1 

but on getseatsinshow method need place ?showid= snippet right under:

http://localhost:1499/home/getseatsinshow/?showid=236 

my razor actionlink looks this:

@html.actionlink("vælg", "getseatsinshow", new { id = item.id }) 

can't seem find problem aftersome show method works fine same results 1 doesn't work.

you have few options.

you're passing parameter id, not showid, whereas controller expects parameter named showid. result, updating anonymous type can pass correct parameter name.

@html.actionlink("vælg", "getseatsinshow", new {  showid = item.id }) 

alternatively, can pass "id" in querystring , allow default mvc binding work it's magic if update controller:

@html.actionlink("vælg", "getseatsinshow", new { id = item.id })  [httppost] public actionresult getseatsinshow(int id) {     ...     return view(realseatlist); } 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -