asp.net mvc - MVC: trying to understand where ActionResult sends it's data -


i have been trying understand online tutorial , stumped. can please tell me text "hello" sent to? message sent directly browser without being placed on page?

public class gohomecontroller : controller

{     public string index()     {         return "hello";     } } 

how's this? controller action needs have return type of actionresult, there many subclasses of class allow various types of responses can influence brute force if like. example"

public actionresult index()  {     response.write("hello world");    return null; } 

the above code writes response stream directly, in example return null. indicates no actionresult needed performed mvc system, typically view specified, view read, parsed , written response stream well.

but typical controller actions have return values, example here how return json, remember view abstraction allow control written response stream.

public actionresult index()  {      return json( new { message="hello world"}); } 

and there typical actionresult directs output .cshtml file:

public actionresult index()  {     return view(); } 

this write response stream using index.cshtml file tied controller namespace or specify name of .cshtml:

public actionresult index()  {     return view("helloworld");   //<-- looks helloworld.cshtml } 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -