首先,这是一个ASP.NET 网站项目。我无法改变这一点,因此我的心痛,但我必须处理它。
现在,我的tagPrefix
中定义了web.config
,如下所示:
<add tagPrefix="vbp" namespace="MyNamespace" />
这允许我引用这个类:
namespace MyNamespace
{
public class RegularExpressionValidatorItem
{
这样的标记:
<vbp:DataRowTextBox ID="EMail" runat="server" Label="E-mail" MaxLength="50"
IsRequired="true" RequiredErrorMessage="Please enter your email address.">
<Regexes>
<vbp:RegularExpressionValidatorItem Type="Email" />
</Regexes>
</vbp:DataRowTextBox>
这在开发中可以精彩,但是当我将它部署到我们的INTG环境时,它失败并出现以下错误:
Exception Source: System.Web
Exception Type: System.Web.HttpException
Exception Message: Unknown server tag 'vbp:RegularExpressionValidatorItem'.
Stack Trace:
at System.Web.UI.TagPrefixTagNameToTypeMapper.System.Web.UI.ITagNameToTypeMapper.GetControlType(String tagName, IDictionary attribs)
at System.Web.UI.MainTagNameToTypeMapper.GetControlType2(String tagName, IDictionary attribs, Boolean fAllowHtmlTags)
at System.Web.UI.MainTagNameToTypeMapper.GetControlType(String tagName, IDictionary attribs, Boolean fAllowHtmlTags)
at System.Web.UI.RootBuilder.GetChildControlType(String tagName, IDictionary attribs)
at System.Web.UI.CollectionBuilder.GetChildControlType(String tagName, IDictionary attribs)
at System.Web.UI.ControlBuilder.CreateChildBuilder(String filter, String tagName, IDictionary attribs, TemplateParser parser, ControlBuilder parentBuilder, String id, Int32 line, VirtualPath virtualPath, Type& childType, Boolean defaultProperty)
at System.Web.UI.TemplateParser.ProcessBeginTag(Match match, String inputText)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
很遗憾,这就是我得到的。部署到IIS时,为什么这会有不同的行为?
答案 0 :(得分:2)
我承认,答案让我感到惊讶。在开发过程中,程序不能包含在Web.config
中,因为没有一个。这是推断。但是在部署时,必须包含在此行中
<add tagPrefix="vbp" namespace="MyNamespace" assembly="MyAssembly" />
这一切的痛苦是我需要到达已发布的文件夹才能知道程序集的名称。现在很酷,因为我知道程序集的名称,但伙计,这就是为什么使用Web应用程序与网站相比要好得多。
无论如何,这就是答案。直到下次朋友......快乐的编码!