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,
LVL 1
ITsolutionWizardAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kaufmed   (⌐■_■)Shot Through the Heart, and You're to Blame, You Give vars a Bad NameCommented:
Have you checked the official MVC site? It has many tutorials, both in video format as well as text.
ITsolutionWizardAuthor Commented:
Yes I did. No one shown me how to have same controller name with different method http
Chris StanyonWebDevCommented:
You can use an attribute for the different verbs:

[HttpGet]
public ActionResult Show(...)
{
   ...
}

[HttpPost]
public ActionResult Show(...)
{
   ...
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

ITsolutionWizardAuthor Commented:
I try it and red line show up
Chris StanyonWebDevCommented:
Where are you getting a red line? Show your code!
kaufmed   (⌐■_■)Shot Through the Heart, and You're to Blame, You Give vars a Bad NameCommented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.