Submit to HttpHandler results in RequestType GET i

2020-05-09 09:23发布

问题:

My ActionHandler.ashx file should be POSTed yet upon entry to ProcessRequest the context.Request.RequestType is always "GET".

Background: This HttpHandler currently works OK (i.e. clicking a link in an email causes my ActionHandler.ashx to be entered and the querystring is processed correctly). For example:

https://mdwdata/CorporateBrain/ActionHandler.ashx?Action=MarkComplete&ID=1024~nzmewoojgnn&CUID=13

is the URL for the link shown as Mark-Complete in the image just below:

But now I am trying to improve it by following this advice in a previous SO thread :

"In the body of the email, instead of sending a link, include an HTML form that contains a button which performs a postback to your server."

Problem Summary: When I click the Submit button, my handler is entered with verb GET not POST (hence, I have no access to the hidden form data in the Request.Form collection.

Here is a snippet (image) of the email body

If I can get the Submit to post the hidden form variables to my handler, then of course I would remove the links. In the debugger, I verified the form data and it looks good me:

I added this line to my web.config file:

<add path="ActionHandler.ashx" verb="GET,POST" type="System.Web.UI.SimpleHandlerFactory" validate="true" />

Also, my email client is Thunderbird.

What would cause the request to be GET instead of POST?

回答1:

The short answer to this problem is that Thunderbird does not POST to the URL in the Action attribute of the HTML form tag. Even the newest version of Thunderbird (version 31.2.0) "ignores" the POST and requests the URL via GET.

The construction of the HTML form is properly done and other email clients I have tested work fine:

  • Microsoft Office 365 Outlook Web App
  • Google GMail

So, I guess I am doing it "right" but some email clients apparently don't support this (even my favorite which is Thunderbird).