Results returned by action methods in the MVC controller

Source: Internet
Author: User

There are several main ways to return in an MVC controller:

1. Content ():

Returns the text type of contentresult, such as "This is an MVC I do".

2. File ():

Returns the contents of a file type Fileresult, such as PDF

3, Httpnotfound ():

Returns the Httpnotfoundresult that contains the 404HTTP status code.

4. JavaScript ():

Returns a javascriptresult containing JavaScript content, such as "function Hello () {alert (hello,world);}".

5. Json ():

Returns the jsonresult of data in JSON format, such as "{" Messge ": hello,world!}".

6, Partialview ()

Returns a Partialviewresult that contains the contents of a partial view (for example, the view may not contain an ending).

7, Redirect ()

Returns a Redirectresult that contains a 302 jump status value and jumps to the given URL. For example, "302http://www.ebuy.com/auctions/recent". This method contains a sibling method Redirectpermanent (), which also returns Redirectresult, but uses a 301 status code to indicate a permanent jump address instead of a temporary address.

8, Redirecttoaction () and Redirecttoroute ()

Similar to redirect (), only space can dynamically query the routing engine to determine external URLs. As with redirect (), they also include a permanent Jump method: Redirecttoactionrermanent () and Redirecttoroutepermanent ().

9. View ()

Returns the Viewresult of the rendered view.

Results returned by action methods in the MVC controller

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.