How to return a string as result from a Controller in ASP.NET MVC 4 Application ?

Do you want to return a string as result from a Controller in ASP.NET MVC 4 Application ? If Yes , you can use return the ContentResult instead of the actual view/partial view.

How to return a string as result from a Controller in ASP.NET MVC 4 Application ?

public ActionResult Index() {

return Content("Ginktage.com is a technology and programming blog");

}

In the above example , the ContentResult is returned as plain text.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply


x

Interesting BlogPosts to read

Passing Array of Integers to ASP.NET Web API REST Service
You can pass an array of integer to an ASP.NET Web Web API REST service by setting the [FromUri] att...
Webinar - Best Practices - Optimizing ASP.NET Performance, Part 1
DevExpress is hosting a webinar on the topic "Best Practices - Optimizing ASP.NET Performance, Part ...
Difference between String and string in C#
When developing an application using C# , one would have noticed the usage of String and string clas...