【发布时间】:2015-04-19 21:17:21
【问题描述】:
我有 jquery 包:
bundles.Add(new ScriptBundle("~/bundle/jquery").Include(
ScriptsPath("jquery-2.0.3.js"),
ScriptsPath("jquery.validate.js"),
ScriptsPath("jquery.validate.unobtrusive.js"),
ScriptsPath("jquery-ui-1.10.3.js"),
ScriptsPath("jquery.validate.unubtrusive.config.js"),
ScriptsPath("jquery.easing.1.3.js "),
ScriptsPath("jquery.unobtrusive-ajax.min.js"),
ScriptsPath("jquery.validate.custom.attributes.js") ...
在用户注册页面上,我有登录和注册表单,因此表单输入的名称中有 Register. 和 Login. 前缀。基本上它看起来像:
<input type="text" ... id="Register_Email" name="Register.Email" />
<input type="password" ... id="Register_Password" name="Register.Password" />
当我以发布模式发布我的应用程序时,我在捆绑文件中收到此错误:
这显然是因为输入名称中的点。如何保存点并解决此问题?我已经尝试过BundleTable.EnableOptimizations = false;,但它没有帮助,我不认为这是合适的解决方案,因为它破坏了捆绑的目的。另请注意,问题仅在 Release 模式下发生。
编辑:
捆绑文件列表包含我自己的一个脚本文件,它包含我的ForbidHtmlAttribude 的客户端验证逻辑:
jquery.validate.custom.attributes.js
jQuery.validator.unobtrusive.adapters.add(
'forbidhtmlattribute',
['htmlregexpattern'],
function (options) {
options.rules['forbidhtmlattribute'] = options.params;
options.messages['forbidhtmlattribute'] = options.message;
}
);
jQuery.validator.addMethod('forbidhtmlattribute', function (value, element, params) {
if (value === null || value === undefined) return true;
var regex = params['htmlregexpattern'];
return !value.match(regex);
}, '');
【问题讨论】:
-
在同一个包中是否有自己的(不是 jQuery)脚本文件?
-
在你开始挖掘之前,你为什么不试试下划线,然后在你的代码中用点替换它。或者尝试其他捆绑工具。
-
@AlexanderDayan,只有一个 -
jquery.validate.custom.attributes.js,它包含我的ForbidHtmlAttribude的客户端验证逻辑。没有像:input[name=Register.Password]这样损坏的选择器 -
@Legends,点是由mvc框架html助手放置的:
ViewData.TemplateInfo.HtmlFieldPrefix = "Login";,@Html.TextBoxFor(m => m.Email),我展示了已经渲染的html -
@Legends,无需抱歉,感谢您的帮助。
标签: c# jquery asp.net-mvc bundle release-mode