2

I'm still kinda fuzzy on mvc mapping to action methods but here's what I understand:

If the app does a form.submit on, say http://mysite/mycontroller/myaction , mvc will a) look for a method named myaction on mycontroller that receives a model as a parameter, and b) create an instance of the model and populate the properties whose names match the form fields. and c) call that method passing that model as a parm. Correct so far?

I want to pass an additional parameter on the url, e.g., my url will be

http://mysite/mycontroller/myaction/someparmvalue

and I hoped I could receive that parm by declaring my method as

public ActionResult Export(MyModel m, string someparm)

but that doesn't seem to work. The model instance is created, the method is called, but the someparm value is null. Am I misunderstanding the way this should work?

2
  • 3
    Do you have a route setup that accepts {someparmvalue}? Commented Jan 6, 2012 at 5:31
  • That was it! thanks. Post it as an answer and I'll accept. Commented Jan 6, 2012 at 6:29

1 Answer 1

2

Be sure to have {someparmvalue} defined in your route.

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.