HTTP POST 到外部 ASPX 表单在某些情况下会导致 HTTP 405 错误

发布于 2024-07-12 04:31:32 字数 858 浏览 8 评论 0 原文

我有一种情况,我们正在聚合来自 N 个客户端的营销数据,其中客户端可以使用他们选择的任何后端托管 HTML 表单,每个表单的操作都指向我们正在处理的路径。托管。 每个客户端都有不同的 URL,没有身份验证(但有一些简单的数据验证),并且通常都工作得很好。

然而,有一个小问题我似乎无法理解。

处理提交数据的 aspx 驻留在一个路径中,我们将其称为 ~/submit/default.aspx。 我们的想法是,我们应该能够向合作伙伴提供一个类似于“http://sample.com/submit/?foo=bar" 作为其表单的操作。 但是,这样做会导致 HTTP 405 错误“资源不允许”。

将表单的操作设置为“http://sample.com/submit/default.aspx” 不过效果很好。

  • Default.aspx 被设置为 IIS 6 中的默认文档名称之一。.aspx
  • 文件扩展名正确映射到正确的 .Net dll,并为映射激活了动词 GET、HEAd、POST 和 DEBUG。

这是我能想到的唯一需要仔细检查的两件事——还有其他人有什么想法吗? 我更喜欢使用 IIS7 的 URL 重写/路由,但不幸的是,这不是一个选择——而且我还有一些额外的要求,其中“干净”的 URL 会更好,所以解决这个问题将是一个相当不错的选择。要解决的核心问题。

I have a situation where we're aggregating what amounts to marketing data from N number of clients, where a client can host a HTML form using any backend of their choice, each with the action of the form pointing to a path that we're hosting. Each client has a different URL, there's no auth (but there is some simple validation of the data) and it's all generally working just fine.

However, there's one small wrinkle that I can't seem to get my head around.

The aspx that is processing the submitted data resides at a path, let's call it ~/submit/default.aspx. The idea is that we should be able to hand to our partner a URL along the lines of "http://sample.com/submit/?foo=bar" as the action of their form. Doing this however results in a HTTP 405 error, "Resource not allowed".

Having the action of the form set as "http://sample.com/submit/default.aspx" works just fine and dandy however.

  • Default.aspx is set as one of the default document names in IIS 6.
  • The .aspx file extension is properly mapped to the correct .Net dll and has the verbs GET, HEAd, POST, and DEBUG activated for the mapping.

Those were the only two things I could think of to double check first--anyone else have any ideas? I'd have preferred to use URL rewriting / routing with IIS7, but that's unfortunately not an option--and I have a number of additional requirements where "clean" URLs will highly be preferable, so solving this problem is going to be a pretty core problem to get through.

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

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

发布评论

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

评论(3

℡寂寞咖啡 2024-07-19 04:31:32

IIRC,如果请求的资源是目录,则 IIS 将仅使用默认文档。 由于第一种情况下请求的资源不是,因此它永远不会通过默认的文档处理程序 - 而是在对未注册的脚本扩展进行 POST 时失败 (405)。

IIRC, IIS will only use the default docs if the requested resource is a directory. Since the requested resource in the first case is not, it'll never make it through the default doc handlers - instead failing on a POST to an unregistered script extension (405).

等数载,海棠开 2024-07-19 04:31:32

它可能取决于“http://sample.com/submit/?foo=bar 的文档类型“...如果您的 IIS 不知道如何处理返回给它的文档类型(然后将其返回给您,即客户端),那么您可能会收到 http 405 错误 - 这意味着它不知道如何在服务器方面处理该文档类型。 也许尝试把类似的东西

在驱动应用程序的 web.config 文件中。 HTTP 处理程序是模块化的代码片段,用 .net 语言编写和编译,如果您熟悉 Java 术语,则可以充当“servlet”。 这是一段向客户端写出一些内容的代码——在您的情况下,可能是 .doc 文件的呈现,以编程方式在您的处理程序类中找到。

it may depend on the document type of "http://sample.com/submit/?foo=bar"... if you IIS doesn't know how to handle the document type being returned to it (which then returns it to you, the client), then you may get an http 405 error - which means that it doesn't know how to handle that document type, server-wise. Maybe try putting something like

in your web.config file that drives the app. HTTP Handlers are modular pieces of code, written and compiled in a .net language, and act as kind of a 'servlet' if you're familiar with Java terms. It's a piece of code that writes out something to the client -- in your case maybe a rendering of a .doc file, found programmatically in your handler class.

情栀口红 2024-07-19 04:31:32

由于某种原因,它没有呈现我的代码示例! 你们需要对“您的答案”文本框的小于和大于符号进行解码和编码......无论如何,

<httpHandlers>
<add verb="your.class.to.handle.doc.files"/>
</httpHandlers>

这就是您的 web.config 文件中应该包含的内容。

for some reason, it didn't render my code sample!! you guys need to decode and encode less than and greater than signs for your "Your Answer" text box.... anyways,

<httpHandlers>
<add verb="your.class.to.handle.doc.files"/>
</httpHandlers>

is what should be in your web.config file.

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