MVC Controller Summary

Source: Internet
Author: User

1. Features

[Authorizefilter] for permission filtering

[HttpGet]

[HttpPost]

2. Parameters

Get method

public actionresult void Get (int id) {}

Submit

[HttpPost]  Public void Post (model) {  varnew  Result ();       if NULL )      return  Json (result);}

Upload image

[HttpPost]  Public void  return"text/html", Encoding.UTF8);}

3. Return type (return method)

return NULL;//returns the emptyresult of a null or void data typereturnView ();//returns a view with the same name as this controllerreturnView (model);//returns a view with the same name as this controller, and passes the model to the viewreturnView ("Success");//returns the specified viewreturnView ("Success", model);//returns the specified view and passes the model to the viewreturnJson (result, jsonrequestbehavior.allowget);//typically submitted by a request to post or AJAX, return JSONreturnContent ("Test Content","text/html");//text type can be specifiedreturnJavaScript ("alter (' Hello ');");//script executed at the client, but does not respond directly to pop-up windows, requiring the page to be called againstringFileName ="~/content/test.zip";//file namestringDownfilename ="file display name. zip";//the file name to display in the download box//returns the binary output of the Fileresult to write to the response, which is generally used as a simple downloadreturnFile (FileName,"Application/octet-stream", Downfilename); // Redirect method: Redirect/redirecttoaction/RedirecttoroutereturnRedirect ("http://www.baidu.com");//go directly to the specified URL addressreturnRedirecttoaction ("Index","Home",New{id="1"});//jump to the specified controllerreturnRedirecttoroute ("Default",New{controller ="Home", action ="Index"});//specify a route to jump

Recommended articles:

Http://www.cnblogs.com/artech/archive/2012/08/13/action-result-01.html

MVC Controller Summary

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.