Reputation: 7146
I am using a MailGun action to forward an inbound email to a REST service on our server. When MailGun posts the email to our server, the subject of the email is duplicated.
I using ASP .NET's HttpRequest
object to read the value of the subject from the POST like so:
string subject = request["Subject"]; //If email subject was "Test" the contents of subject would be "Test,Test"
Why is this happening?
Upvotes: 4
Views: 501
Reputation: 463
Just ran into the same issue- it looks like MVC's FormCollection model binder is merging in a case insensitive way, but the property model binder is case sensitive. I added "string subject" to my method, and it's only binding to one value:
public ActionResult Receive(FormCollection form, string subject)
Upvotes: 2
Reputation: 7146
The reason is that MailGun is passing the subject in twice, once as "subject" and again as "Subject". This was done for backward compatibility. Apparently .NET is merging them into the one field.
Upvotes: 3