Tutorial for the. NET MYMVC framework to process return values

Source: Internet
Author: User
The time the MYMVC framework handles the return value is in the ExecuteAction method (preceded by that piece of code).
Here is a simple supplementary explanation.

I have defined an interface for the action result:

public interface iactionresult{    void Ouput (HttpContext context);

4 types of ActionResult are implemented within the framework:

<summary>///represents a user control result (the user control will be executed by the framework)///</summary>public sealed class ucresult:iactionresult///< summary>///represents the result of a redirect//</summary>public sealed class redirectresult:iactionresult///<summary>/// A JSON object result///</summary>public sealed class jsonresult:iactionresult///<summary>///represents a page result (the page will be executed by the framework)/ </summary>public Sealed class Pageresult:iactionresult

To output the return value, not only using the Iactionresult interface, I also use the following call:

Context. Response.Write (Result. ToString ());

Do not underestimate the invocation of ToString ().
For a custom data type, it can be used to control the final output to the client is JSON or XML, or your own definition of the text serialization format (such as a special delimiter stitching), so it has enough capacity to replace the Jsonresult type, It also does not affect unit testing of the action.
The strong reason for ToString () is that it is a virtual method that can be overridden by a derived class.

So, if you only want to return a data entity object to the client, you can implement the Iactionresult interface and override the ToString method.

"Recommended"

1. Special recommendation : "PHP Programmer Toolkit" V0.1 version download

2. asp free Video Tutorial

3. an entry-level. NET MVC Instance

4. MYMVC The process of finding action in the box

5. the. NET MYMVC Framework performs an action-detailed procedure

6. the. NET MYMVC Framework How to assign values to a method tutorial

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.