Introduction

ASP.NET Boilerplate is integrated to ASP.NET MVC Controllers via Abp.Web.Mvc nuget package. You can create regular MVC Controllers as you always do. Dependency Injection properly works for regular MVC Controllers. But you should derive your controllers from AbpController, which provides several benefits and better integrates to ASP.NET Boilerplate.

ASP.NET样板集成到ASP.NET的MVC控制器通过abp.web.mvc NuGet包。您可以像平常一样创建常规的MVC控制器。依赖注入适用于常规MVC控制器。但是你应该得到你abpcontroller控制器,它提供了几个好处,更好的融入到ASP.NET样板。

AbpController Base Class

This is a simple controller derived from AbpController:

public class HomeController : AbpController
{
public ActionResult Index()
{
return View();
}
}

Localization

AbpController defines L method to make localization easier. Example:

public class HomeController : AbpController
{
public HomeController()
{
LocalizationSourceName = "MySourceName";
} public ActionResult Index()
{
var helloWorldText = L("HelloWorld"); return View();
}
}

You should set LocalizationSourceName to make L method working. You can set it in your own base controller class, to not repeat for each controller.

Filters

Exception Handling & Result Wrapping(异常处理与结果包装)

All exceptions are automatically handled, logged and a proper response is returned to the client. See exception handling documentation for more.

所有异常都会自动处理、记录,并将适当的响应返回给客户机。查看更多的异常处理文档。

ASP.NET Boilerplate also wraps action results by default if return type is JsonResult (or Task<JsonResult> for async actions).

You can change exception handling and wrapping by using WrapResult and DontWrapResult attributes for controllers or actions or from startup configuration (using Configuration.Modules.AbpMvc()...) globally. See ajax documentation for more.

你可以改变的异常处理和包装用的启动配置控制器或动作或wrapresult和dontwrapresult属性(使用配置模块。abpmvc())。更多的见ajax文档。

Audit Logging(审计日志)

AbpMvcAuditFilter is used to integrate to audit logging system. It logs all requests to all actions by default (if auditing is not disabled). You can control audit logging using Audited and DisableAuditing attributes for actions and controllers.

abpmvcauditfilter是用来整合审计日志系统。默认情况下,它将所有请求记录到所有操作(如果没有禁用审核)。你可以控制审计日志审计和disableauditing使用动作和控制器属性。

Validation

AbpMvcValidationFilter automatically checks ModelState.IsValid and prevents execution of the action if it's not valid. Also, implements input DTO validation described in the validation documentation.

Authorization

You can use AbpMvcAuthorize attribute for your controllers or actions to prevent unauthorized users to use your controllers and actions. Example:

public class HomeController : AbpController
{
[AbpMvcAuthorize("MyPermissionName")]
public ActionResult Index()
{
return View();
}
}

You can define AllowAnonymous attribute for actions or controllers to suppress authentication/authorization. AbpController also defines IsGranted method as a shortcut to check permissions.

See authorization documentation for more.

Unit Of Work

AbpMvcUowFilter is used to integrate to Unit of Work system. It automatically begins a new unit of work before an action execution and completes unit of work after action exucition (if no exception is thrown).

You can use UnitOfWork attribute to control behaviour of UOW for an action. You can also use startup configuration to change default unit of work attribute for all actions.

Anti Forgery(防伪)

AbpAntiForgeryMvcFilter is used to auto protect MVC actions for POST, PUT and DELETE requests from CSRF/XSRF attacks. See CSRF documentation for more.

Model Binders

AbpMvcDateTimeBinder is used to normalize DateTime (and Nullable<DateTime>) inputs using Clock.Normalize method.

ABP框架系列之三十五:(MVC-Controllers-MVC控制器)的更多相关文章

  1. ABP框架系列之三十二:(Logging-登录)

    Server Side(服务端) ASP.NET Boilerplate uses Castle Windsor's logging facility. It can work with differ ...

  2. ABP框架系列之三十四:(Multi-Tenancy-多租户)

    What Is Multi Tenancy? "Software Multitenancy refers to a software architecture in which a sing ...

  3. ABP框架系列之三十九:(NLayer-Architecture-多层架构)

    Introduction Layering of an application's codebase is a widely accepted technique to help reduce com ...

  4. ABP框架系列之三十六:(MVC-Views-MVC视图)

    Introduction ASP.NET Boilerplate is integrated to MVC Views via Abp.Web.Mvc nuget package. You can c ...

  5. ABP框架系列之三十八:(NHibernate-Integration-NHibernate-集成)

    ASP.NET Boilerplate can work with any O/RM framework. It has built-in integration with NHibernate. T ...

  6. ABP框架系列之十五:(Caching-缓存)

    Introduction ASP.NET Boilerplate provides an abstraction for caching. It internally uses this cache ...

  7. ABP框架系列之四十五:(Quartz-Integration-Quartz-集成)

    Introduction Quartz is a is a full-featured, open source job scheduling system that can be used from ...

  8. ABP框架系列之三十:(Javascript-API-Javascript-API)

    ASP.NET Boilerplate provides a set of objects and functions that are used to make javascript develop ...

  9. ABP框架系列之五十四:(XSRF-CSRF-Protection-跨站请求伪造保护)

    Introduction "Cross-Site Request Forgery (CSRF) is a type of attack that occurs when a maliciou ...

随机推荐

  1. 在pycharm_2018.2版本中开启Flask的debug的方法 (不要用命令:python **.py启动)

    断点后,先ctl+c关闭控制台程序,再点击debuger调试 问题描述:在pycharm_2018.2版本中,我明确开启了debug,代码如下所示: from flask import Flask a ...

  2. iOS开发SDWebImageOptions理解

    iOS开发SDWebImageOptions理解 原文 http://www.cnblogs.com/WJJ-Dream/p/5816750.html typedef NS_OPTIONS(NSUIn ...

  3. Angularjs启动入口, splash画面,与加快启动的技巧

    Angularjs启动入口, splash画面,与加快启动的技巧 Angularjs启动入口 * 自动响应DOMContentLoaded event * 从ngApp指定的入口启动: 在angula ...

  4. Vue keep-alive的总结

    1.基本用法 vue2.0提供了一个keep-alive组件用来缓存组件,避免多次加载相应的组件,减少性能消耗. <keep-alive> <component> <!- ...

  5. Oracle 循环查询

    select * from sys_department start with departmentid = '0303e461-2454-4d5a-bfea-2cd5a4c064c6' connec ...

  6. python实战博客

    2018-10-31 更新Logging日志记录以及异常捕获 感谢廖大教程.Python实战 直接在闲置的服务器上开发.阿里云Centos 6.8 64位. 1 搭建开发环境 Python 环境是Py ...

  7. PyCharm下的pywin32安装及使用

    转载http://www.mamicode.com/info-detail-2145088.html

  8. Spring4新特性

    参考 : https://jinnianshilongnian.iteye.com/blog/1990081

  9. JavaScript倒计时实现

    /** * 倒计时函数 * @param {String}} endTime 终止时间戳 */ const countDown = (endTime, callback) => { const ...

  10. byobu 禁止窗口名称随目录变化

    It looks like the config set-window-option -g automatic-rename off doesn't work. When I added the fo ...