官术网_书友最值得收藏!

Chapter 2. Taking Action in Your Controllers

In this chapter, we will cover:

  • Exposing JSON using a JsonResult with Json.NET
  • Creating custom action result to return an image
  • Constraining an image's size from an ImageResult
  • Creating a CAPTCHA system
  • Generating a PDF order summary
  • Implementing a controller factory for use with StructureMap

Introduction

This chapter is all about the controller—a very important ingredient to the Model View Controller recipe. In this chapter, we will take a look at a few things that can be done with actions and the controllers that host them. We will take a look at some flexibility that is now provided in .NET 4 with optional parameters. Next, we will create a custom action that exposes JSON. After that we will look at how to return image data from an action. With that under our belt, we will implement an action that not only returns an image, but is also able to constrain the sizes of that image. This will be followed by building an image-based CAPTCHA system. Next, we will implement an action that returns a PDF. And lastly, we will take a look at how to implement a controller factory for use with an Inversion of Control (IoC) product, such as StructureMap.

主站蜘蛛池模板: 民乐县| 长乐市| 连城县| 巴彦淖尔市| 闻喜县| 黄冈市| 张家港市| 北川| 朔州市| 息烽县| 萨嘎县| 绥江县| 集贤县| 江都市| 丰县| 海阳市| 化隆| 东乡族自治县| 吴堡县| 体育| 剑阁县| 连江县| 雅江县| 侯马市| 雅江县| 蒙城县| 张掖市| 江陵县| 梁平县| 河北省| 邵阳县| 固阳县| 新化县| 迭部县| 中西区| 明溪县| 闽侯县| 建阳市| 寻甸| 荥阳市| 潜江市|