Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




C# and ASP.NET MVC (Model view controller) interview questions and answers: - How can we restrict MVC actions to be invoked only by GET or POST?

We can decorate the MVC action by “HttpGet” or “HttpPost” attribute to restrict the type of HTTP calls. For instance you can see in the below code snippet the “DisplayCustomer” action can only be invoked by “HttpGet”. If we try to make Http post on “DisplayCustomer” it will throw a error.

[HttpGet]

        public ViewResult DisplayCustomer(int id)

        {

            Customer objCustomer = Customers[id];

 

            return View("DisplayCustomer",objCustomer);

        }

  Below is an important c# interview question and answers video 





Share this article   |    Print    |    Article read by 10403 times
Author:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers
Related Articles: No related article
Related Interview Questions: No related interview question