Skip to main content

Posts

Showing posts from October, 2016

Enable or disable client side validations in mvc4

We can enable or disable the client side validations in MVC4 by doing simple configuration / code changes. For enable / disable validations application level: We can use any one of the below two methods (web.config change or Global.asax.cs change) Configuration change in web.config < appSettings >     < add   key = " ClientValidationEnabled "   value = " true "   />     < add   key = " UnobtrusiveJavaScriptEnabled "   value = " true "   /> </ appSettings > Code change in Global.asax.cs file protected   void   Application_Start() {       HtmlHelper .ClientValidationEnabled =   true ;       HtmlHelper .UnobtrusiveJavaScriptEnabled =   true ; } For enable/disable validation in a particular view   set the below two properties in the View Razor code. @{       ViewBag.Title =   "Index" ;...

3 easy steps to create WebAPI documentations

By default, the API Help page created by   Microsoft . AspNet . WebApi . HelpPage   contains no documentation. We will see all   ApiController   actions are listed with   No   documentation available . To enable the documentation, we just need to follow three easy steps. Step 1 - on the controller level For the testing purpose, a new   ApiController   is created, named   DocumentationsController . public class DocumentationsController : ApiController { // GET api/documentation public IEnumerable <string> Get () { return new string [] { "value1" , "value2" }; } .... Hit   ///   ahead of the controller action to get the documentation. // GET api/documentation /// <summary> /// This is how we create a documentation /// </summary> /// <returns></returns> public IEnumerable <string> Get () .... For more information on what can be docume...