实例化的HtmlHelper ASP.NET MVC的位置 [英] Location of HtmlHelper instantiation for ASP.NET MVC

查看:119
本文介绍了实例化的HtmlHelper ASP.NET MVC的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图调试问题,其中的HtmlHelper是扩展方法无效。奇怪的是调试器声称它的完全填充,但是我始终弄空例外。我试图找出其中的HtmlHelper应该在试图看到我的问题可能是被实例化。

I am trying to debug a problem where HtmlHelper is null in extension methods. Oddly the debugger claims it's fully populated, however I consistently get null exceptions. I'm trying to figure out where HtmlHelper should being instantiated in an attempt to see where my problem may be.

应该在哪里的HtmlHelper被实例化?

Where should HtmlHelper be Instantiated?

更新:我特别想实现扩展在这里找到,的 HTTP://chriscavanagh.word$p$pss.com/2009/06/11/mvc-authorizedactionlink/ ,一个母版中。在MVC模板的HomeController.Index出现的错误()。还有一些插件/ virtualpathing可能会引起问题(试图避免这种情况可以蠕虫),但是,code中的code是基本相同这里找到:的 HTTP://www.$c$cplex.com/unifico 。不过,我不希望所有这一切的细节困难的人。

Update: In particular I am trying to implement the extension found here, http://chriscavanagh.wordpress.com/2009/06/11/mvc-authorizedactionlink/, within a masterpage. The error occurs on the MVC template's HomeController.Index(). There are some 'plugins'/virtualpathing that may be causing the problem (trying to avoid this can of worms), but, code the code is essentially the same as found here: http://www.codeplex.com/unifico. However, I don't want to trouble anyone with the details of all of that.

推荐答案

在的HtmlHelper由ASP.NET MVC内部实例化 - 这不是你一般应需要担心的东西。正是它被实例化取决于你正在使用它。

The HtmlHelper is instantiated internally by ASP.NET MVC - it's not something you should generally need to worry about. Exactly where it gets instantiated depends on where you are using it.

它被实例化的主要场所是的ViewPage的 InitHelpers()方法。

The main place it gets instantiated is ViewPage's InitHelpers() method.

在ViewUserControls它被点播在HTML属性的getter创建。

In ViewUserControls it gets created on-demand in the getter of the Html property.

在ViewMasterPages它只是使用的ViewPage的HTML属性。

In ViewMasterPages it just uses the ViewPage's Html property.

这篇关于实例化的HtmlHelper ASP.NET MVC的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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