title: How to allow C# Web API to only accept plain-text Put request?
body: <p>Why does my action method allow JavaScript to Put?</p>
  
  <p>It lets through alert('hello');, but I only want to allow plain text.</p>
  
  <p>I am using System.Web.Http ApiController.</p>
  
  <pre><code>  public class AppController : ApiBaseController
  {
      public AppController(IReadyToWorkProcessor processor) : base(processor) { }
  
      [HttpPut]
      public IHttpActionResult Put(Guid readyToWorkGuid, [FromBody] PersonalDetailsVW newPersonalDetails)
      {
  
         newPersonalDetails.ReadyToWorkGuid = readyToWorkGuid.ToString();
  
          int? TeacherID = Processor.GetTeacherIdFromReadyToWorkGuid(readyToWorkGuid);
  
          if (TeacherID != null)
          {
              Processor.PersonalDetailsService.ProcessPersonalDetails(newPersonalDetails, ModelState, (int)TeacherID);
  
              ResponseMessage response = new ResponseMessage();
  
              if (ModelState.IsValid)
              {
                  response.Result = true;
                  response.Message = "Section Completed";
                  response.SectionComplete = true;
                  return Ok(response);
              }
              else
              {
                  string errorList = UtilityHelpers.ModelStateErrors(ModelState);
                  response.Result = true;
                  response.SectionComplete = false;
                  response.Message = "Saved .... Section not completed yet, the following have not filled correctly: " + errorList;
                  return Ok(response);
              }
  
          }
          return NotFound();
  
      }
  }
  </code></pre>