asp论文外文翻译---从底层了解aspnet的结构-jsp程序(编辑修改稿)内容摘要:
andler)的执行。 这个处理器将被安装用于处理指定的扩展。 在 IIS中, .aspx经由“应用程序扩展”被映射到 ISAPI 的 dll文件:。 每一个触发 的请求,都必须经由一个已经注册的,并且指向 扩展名来标识。 注: ISAPI 是自定义 Web请求处理中第一个并且具有最高性能的 IIS入口点。 依靠扩展名, ,该处理器则负责处理这个请求。 举个例子, WebServices的扩展名 .asmx不会把一个请求路由到磁盘上的某一个页面,而是会路由到在定义中附加了指定特性( WebMethodAttribute)的类,此特性会把它标识成一个 Web Services 的实现。 许多其它的处理器将随着 一起被安装。 当然也可以定义你自己的处理器。 在 IIS里所有的 HttpHandler 被映射并指向 ISAPI 扩展,并且这些 HttpHandler也都在 ,用于把请求路由到指定的 HTTP处理器里执行。 每一个处理器都是一个 .NET类,用于处理指定的扩展。 而这些处理器可以处理简单到只有几行代码的 Hello World,也可以处理复杂到类似 的页面以及执行 WebService。 就目前而言,仅仅需要理解扩展就是一种基本的映射机制, 用它可以从 ISAPI 里获取一个请求,然后把请求路由到指定处理该请求的处理器中。 6 原文 2 Thirteen MVC extensibility points you have to know Abstract One of the main design principles MVC has been designed with is extensibility. Everything (or most of) in the processing pipeline is replaceable so, if you don’t like the conventions (or lack of them) that MVC uses, you can create your own services to support your conventions and inject them into the main pipeline. In this post I’m going to show 13 extensibility points that every MVC developer should know, starting from the beginning of the pipeline and going forward till the rendering of the view. 1. RouteConstraint Usually you could put some constrains on url parameters using regular expressions, but if your constrains depend on something that is not only about the single parameter, you can implement the IRouteConstrains’s method and put your validation logic in it. One example of this is the validation of a date: imagine an url that has year, month and date on different url tokens, and you want to be able to validate that the three parts make a valid date. 2. RouteHandler Not really specific to MVC, the RouteHandler is the ponent that decide what to do after the route has been selected. Obviously if you change the RouteHandler you end up handling the request without MVC, but this can be useful if you want to handle a route directly with some specific HttpHanlders or even with a classic WebForm. 3. ControllerFactory The controller factory is the ponent that, based on the route, chooses which controller to instantiate and instantiate it. The default factory looks for anything that implements IController 7 and whose name ends with Controller, and than create an instance of it through reflection, using the parameterless constructor. But if you want to use Dependency Injection you cannot use it, and you have to use a IoC aware controller factory: there are already controller factory for most of the IoC containers. You can find them in MvcContrib or having a look at the Ninject Controller Factory. 4. ActionInvoker ActionInvoker is responsible for invoking the action based on it’s name. The default action invoker looks for the action based on the method name, the action name and possibly other selector attributes. Then it invokes the action method together with any filter defined and finally it executes the action result. If you read carefully you probably understood that most of the execution pipeline is inside the logic of the default ControllerActionInvoker class. So if you want to change any of these conventions, from the action method’s selection logic, to the way parameters are mapped to action parameters, to the way filters are chosen and executed, you have to extend that class and override the method you want to change. A good example of this, is the NinjectActionInvoker I developed to allow injection of dependencies inside filters. 5. ActionMethodSelectorAttribute Actions, with the default action invoker, are selected based on their name, but you can finer tune the selection。asp论文外文翻译---从底层了解aspnet的结构-jsp程序(编辑修改稿)
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。
用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。