You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ASP.NET WebForms UnobtrusiveValidationMode jQuery映射错误已加配置仍无效求解决

Fixing "WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'" Error

Hey there, I’ve run into this exact issue before with ASP.NET WebForms, so let’s walk through some solutions that should get you past this error, even after setting ValidationSettings:UnobtrusiveValidationMode to None.

1. Double-check your web.config configuration placement

Sometimes the issue is simply that your appSettings entry is nested incorrectly in the web.config file. It needs to be a direct child of the root <configuration> node, not inside another section like <system.web> or elsewhere. Here’s the correct structure:

<configuration>
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
  </appSettings>
  <!-- Other configuration sections like system.web, connectionStrings, etc. -->
</configuration>

If you had it nested somewhere else, moving it to the correct spot should resolve the error immediately.

2. Configure the ScriptResourceMapping for jQuery (if you want to keep Unobtrusive Validation enabled)

If you’d prefer not to disable Unobtrusive Validation, you need to properly map the jQuery resource so WebForms can find it. Add this code to your Global.asax.cs file inside the Application_Start method:

protected void Application_Start(object sender, EventArgs e)
{
    // Register jQuery ScriptResourceMapping
    ScriptManager.ScriptResourceMappings.Add("jquery", new ScriptResourceDefinition
    {
        Path = "~/Scripts/jquery-3.6.4.min.js", // Update this to your jQuery file path/version
        DebugPath = "~/Scripts/jquery-3.6.4.js",
        CdnPath = "https://code.jquery.com/jquery-3.6.4.min.js",
        CdnDebugPath = "https://code.jquery.com/jquery-3.6.4.js"
    });
}

Make sure the Path points to the actual jQuery file in your project’s Scripts folder (adjust the version number to match what you have).

3. Verify jQuery is loaded in your pages/master page

Even if you have the right config, if jQuery isn’t actually being loaded on the page, the validation system will still throw this error. Ensure you have a reference to jQuery in your master page or individual WebForms pages, like this:

<script src="~/Scripts/jquery-3.6.4.min.js"></script>

Place this reference before any WebForms validation scripts or the ScriptManager control to make sure jQuery loads first.

4. Check for conflicting configuration settings

Occasionally, other validation-related settings in web.config can override your UnobtrusiveValidationMode setting. Look for entries like <pages validateRequest="true"> or other ValidationSettings keys in appSettings that might be conflicting. Remove or adjust those if they’re interfering.

Give these steps a try—most of the time, it’s either a misplaced config entry or a missing jQuery mapping/reference that’s causing the problem.

内容的提问来源于stack exchange,提问作者M.Carreira

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:26:43