在MVC中扩展WebFormView [英] Extending WebFormView in MVC

查看:82
本文介绍了在MVC中扩展WebFormView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想扩展WebFormViewEngine以便执行一些后处理-我希望它完成它的工作,然后将Html交还给我,以便对它做一些最后的修改.它需要作为View/ViewEngine完成,因为我需要访问ViewData.

I want to extend the WebFormViewEngine so that I can perform some post-processing - I want it to do it's stuff, then hand me the Html back, so I can do put some final touches to it. It needs to be done as a View/ViewEngine because I need access to the ViewData.

不幸的是,似乎没有办法从WebFormView取回HTML,也没有办法将自定义的HtmlTextWriter交给WebFormView或ViewPage.

Unfortunately there seems to be no way to get the Html back from the WebFormView, and no way to hand a custom HtmlTextWriter to the WebFormView or ViewPage.

肯定有办法做到这一点吗?不?

Surely there's a way to do this? No?

小查尔瓦

推荐答案

您可以使用操作过滤器执行此操作.在asp.net/mvc上查看本教程.您要使用一个ResultsFilter.

You can use Action Filters to do this. Check out this tutorial at asp.net/mvc. You want to use a ResultsFilter.

或者,您可以替代Controller的虚拟OnResultExecuted方法.

As an alternate, you can override the virtual OnResultExecuted method of the Controller.

这篇关于在MVC中扩展WebFormView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆