Walk into asp: [5]action's return

Source: Internet
Author: User

ASP. NET MVC provides a variety of return methods, on the one hand, the view can be reused, on the other hand, flexible and powerful, have a direct return to the view, return JSON, return the file stream, return to the same controller action, return to another controller and so on.

1 The most common is to return directly to the view, so that you can directly return to the corresponding view folder under the same name as the action, and this view method, can take parameters, the diagram with the model parameters of the view, can be used as a display list

2 can also return Action,redirecttoaction () under the same controller, that is, the index method that returns the same controller directly; in fact, this method has other overloaded methods, such as the second parameter is the controller name, You can specify a different controller, two of which are equivalent in the second diagram

3 Another option is to return the specified URL, which is redirect (), which is actually equivalent to the three return methods.

4 in some special requirements, you can return the JSON, the diagram can be used to asynchronously determine whether the domain name already exists, if there is no return true, otherwise return false

5 finally introduces the return of a file stream, generally used for file download; The return value is Filepathresult and the file () method is called when returned

6 The Return of action is introduced here, I wish you a happy study!

I original, reproduced please indicate the source, better visual typesetting please: Http://t.cn/RPgNtoB

Walk into asp: [5]action's return

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.