Link to home
Start Free TrialLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

asked on

mvc post and get

I have simple mvc project with c#. and I only want to post <input type="text" id="email" name="email">
To controller. Assume the view name is "Quote"

and I want to use same controller name - one for get, and one for post.

Can you show me in codes how it works? I am new in .net mvc.

Thanks,
Avatar of kaufmed
kaufmed
Flag of United States of America image

Have you checked the official MVC site? It has many tutorials, both in video format as well as text.
Avatar of ITsolutionWizard

ASKER

Yes I did. No one shown me how to have same controller name with different method http
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I try it and red line show up
Where are you getting a red line? Show your code!
GET may or may not have parameters. By convention, GET parameters are passed via the URL.
POST may or may not have parameter. By spec, POST parameters are passed via the body. (I believe nothing in the spec forbids URL parameters.)

In MVC, however you send parameters they come into the actions as parameters--regular old C# parameters. GETs are usually simple types; POSTs are usually complex types (i.e. classes). Keep in mind that when you're inside your action, that is C# code. As such, you have to follow C# rules. If you have two actions (i.e. methods) with the same name, then the parameter list has to vary--either in number of parameters or in data types (or both). Simply attributing two actions with HttpGet or HttpPost is not enough to let the compiler differentiate between which action to invoke. Your bound to C# rules once you're working inside the controller.