首先,这是一个 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 时会有不同的行为?