为什么 IIS 通配符映射会破坏我的 AJAX 调用?

发布于 2024-08-01 16:30:10 字数 547 浏览 9 评论 0原文

我正在尝试使用 jQuery 进行一些 AJAX 调用,但因为我在 IIS 6 中打开了通配符映射(到 .NET),所以它似乎不起作用。 禁用映射使一切都神奇地工作。

我已将 Web 方法属性放在 .aspx 页面和 .asmx Web 服务中的方法上,但都不起作用。 以下是我用于 AJAX 调用的示例 URL:

localhost/UserChecker.aspx/CheckIfUserEmailsExists

localhost/UserChecker.asmx/CheckIfUserEmailsExists

我认为这一定与 .NET 解释 URL 的方式有关,但我不完全确定原因。 更重要的是,除了禁用通配符映射之外,我不知道如何修复它! 还有别的办法吗???

更新

我正在使用的 CMS (Kentico) 会执行一些 URL 路由,但即使我跳过 global.asax.cs 代码中的路由,我仍然会收到 404。
提前致谢!

I'm trying to use jQuery to make some AJAX calls, but because I have wild card mapping (to .NET) in IIS 6 turned on, it doesn't seem to work. Disabling the mapping makes everything magically work.

I've put the web method attribute on methods in both an .aspx page and an .asmx web service, but neither work. Here is the sample URL that I am using for the AJAX calls:

localhost/UserChecker.aspx/CheckIfUserEmailsExists

localhost/UserChecker.asmx/CheckIfUserEmailsExists

I figure it must be something with the way .NET is interpreting the URL's but I'm not entirely sure why. More importantly, I'm not sure how to fix it, other than to disable wild card mapping! Is there any other way???

UPDATE

The CMS I am using (Kentico) does some URL routing, but even if I skip over the routing in the global.asax.cs code, I still get a 404.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

忘东忘西忘不掉你 2024-08-08 16:30:10

使用 IIS 上的通配符映射,将首先通过通配符处理程序运行初始请求。 这将在 CMS 进行任何 URL 重写(或 URL 路由)之前完成。

我认为这就是您收到 404 的原因。

您还可以尝试禁用通配符映射上的“验证文件存在”复选框,以适应实际 URL 稍后将被重写为其他内容的情况。

With the wildcard mapping on IIS will run the initial request via the wildcard handler first. This will be done BEFORE any URL rewriting (or URL routing) by your CMS.

I think that is why you are getting 404.

You can also try to disable "verify file exists" checkbox on the wildcard mapping to cater for the scenario when the actual URL will be later rewritten to something else.

淡写薰衣草的香 2024-08-08 16:30:10

这不是一个完整的答案,但我希望它能为您指明解决方案的方向。

您是否尝试过直接在浏览器中访问 url 并使用一些放置良好的断点来追踪问题?

如果您收到 404,听起来您的路由规则不起作用。

[如果您可以提供有关您所看到的行为的更多信息,我会更新此内容]

更新

我认为可能发生的情况是这样的:

您正在为具有扩展名的文件提供单独的映射(在这些情况下为 .aspx和 .asmx):

localhost/UserChecker.aspx/CheckIfUserEmailsExists

localhost/UserChecker.asmx/CheckIfUserEmailsExists

当您关闭通配符映射时,将使用这些映射,并且“/CheckIfUserEmailsExists”将被处理使用或忽略。
当您打开通配符映射时,您的路由不会通知您的应用程序如何正确“路由”。

如果您删除了扩展名(打开通配符映射),以下工作是否有效?

本地主机/UserChecker/CheckIfUserEmailsExists

This is not a complete answer but I hope it points you in the direction of a solution.

Have you tried accessing the url directly in a browser and using some well placed breakpoints to track down the problem?

If you're getting 404s it sounds like your rules for routing aren't working.

[I'll update this if you can give a little more info about the behaviour you're seeing]

UPDATE

I think what might be happening is this:

You're providing a seperate mapping for your files with extensions (in these cases .aspx and .asmx):

localhost/UserChecker.aspx/CheckIfUserEmailsExists

localhost/UserChecker.asmx/CheckIfUserEmailsExists

These mappings are being used when you turn the wild card mappings off, and the '/CheckIfUserEmailsExists' is handled used or ignored.
When you turn on the wildcard mappings your routing isn't informing your app how to 'route' correctly.

If you removed the extensions (with wildcard mappings turned on) does the following work?

localhost/UserChecker/CheckIfUserEmailsExists

孤独陪着我 2024-08-08 16:30:10

我建议检查 CMS 框架之外的 URl; 问题必须出在 URL 路由上。 不确定如果没有通配符映射它是如何工作的。

需要理解的问题:
1.尝试不使用通配符映射时,您的 CMS 是否正在运行?
2、这个CMS系统如何与IIS交互; IASPI 动态链接库? 或者 HTTP 处理程序/模块?

I suggest checking the URl outside of your CMS framework; Issue has to be with the URL routing. No tsure how it was working without the wild card mapping.

Questions to understand:
1.Did you have your CMS running when trying without wild card mapping?
2. How does this CMS system interact with IIS; IASPI dll ? or HTTP Handlers/modules?

倾城月光淡如水﹏ 2024-08-08 16:30:10

将适当的 URL 添加到排除列表:使用“站点管理器”->“设置”选项卡中的“排除的 URL”设置。 (基本帮助文档

Add the appropriate URLs to the exclusion list: Use the "Excluded URLs" setting in the Site Manager->Settings tab. (basic help documentation)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文