I have a Controller Action that is trying to return plain text to an AJAX call. E.G.-
[HttpPost]
public ActionResult SubmitAttachment(int id, HttpPostedFileBase theFile){
...
...
return Content("Success");
}
In my javascript function which is doing the ajax call, I am expecting the response text to just be “Success”, but I’m getting "<head></head><body>Success</body>" instead.
In 99% of my other controller actions, I don’t have this issue. The only thing that I can think of that makes this different is because the AJAX call to “SubmitAttachment” is a form POST with the “enctype=multipart/form-data”, where as the other AJAX calls aren’t uploading any files.
Has anyone encountered this before? If so…how would I just have it return plain text?
NOTE: I have also tried return Content("Success", "text/plain"), but that just adds additional <pre></pre> tags around the “Success” string.
Unable to reproduce the behavior:
Controller:
View:
When the form is submitted the server returns only
"Success".