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,
.NET ProgrammingC#ASP.NET

Avatar of undefined
Last Comment
kaufmed
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ITsolutionWizard

ASKER

I try it and red line show up
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Where are you getting a red line? Show your code!
Avatar of kaufmed
kaufmed
Flag of United States of America image

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.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo