zoukankan      html  css  js  c++  java
  • ASP.NET MVC Tutorial 1) Controller Action

    Return Types of Action:

    1. Content()
    Returns a ContentResult that renders arbitrary text, e.g., “Hello, world!”


    2. File()
    Returns a FileResult that renders the contents of a file, e.g., a PDF.


    3. HttpNotFound()
    Returns an HttpNotFoundResult that renders a 404 HTTP status code response.


    4. JavaScript()

    Returns a JavaScriptResult that renders JavaScript, e.g., “function hello() { alert(Hello, World!); }”.


    5. Json()
    Returns a JsonResult that serializes an object and renders it in JavaScript Object
    Notation (JSON) format, e.g., “{ “Message”: Hello, World! }”.


    6. PartialView()
    Returns a PartialViewResult that renders only the content of a view (i.e., a view
    without its layout).

    7. Redirect()
    Returns a RedirectResult that renders a 302 (temporary) status code to redirect
    the user to a given URL, e.g., “302 http://www.ebuy.com/auctions/recent”. This
    method has a sibling, RedirectPermanent(), that also returns a RedirectResult, but
    uses HTTP status code 301 to indicate a permanent redirect rather than a temporary
    one.


    8. RedirectToAction() and RedirectToRoute()
    Act just like the Redirect() helper, only the framework dynamically determines
    the external URL by querying the routing engine. Like the Redirect() helper, these
    two helpers also have permanent redirect variants: RedirectToActionPermanent()
    and RedirectToRoutePermanent().


    9. View()
    Returns a ViewResult that renders a view.

     Action Filters:

    eg:

    [Authorize]
    public ActionResult Profile()
    {
      // Retrieve profile information for current user
      return View();
    }

    技术改变世界
  • 相关阅读:
    POJ 1149
    最小费用最大流邻接表模板
    poj 1724 最短路+优先队列(两个约束条件)
    hdu 4786 最小生成树与最大生成树
    hdu 4081 最小生成树变形
    poj 3228 二分+最大流
    poj 2516 最小费用最大流
    hdu 3605 二分图多重匹配
    hdu 3605 最大流sap+二进制思想(啊啊)
    hdu 3572 最大流判断满流
  • 原文地址:https://www.cnblogs.com/davidgu/p/3126615.html
Copyright © 2011-2022 走看看