SendGrid Parse API on ASP.NET MVC
I wonder if somebody has used SendGrid's Parse AP开发者_开发百科I to receive emails using ASP.NET MVC.
I set up my SendGrid account according to their instructions: http://sendgrid.com/documentation/display/api/Parse
And when I send an email to any address on my site I get my ASP.Net MVC ActionMethod called, however I cannot see any information on the request.
I tried accessing the Request object inside the action method and it says that the Length is around 12KB, but I don't see my information. - Request.Form doesn't have anything - Request.Files.Length is 0 - Request.InputStream.Length is 0
Also if I create a FormCollection parameter it comes empty, and if I set string arguments in the Action Method for the common fields (to, from, html, text) they are all null when the request is processed.
Has anybody used this successfully? what am I missing?
Thanks
You need to turn off input Validation. It will throw exceptions on fields where there is data. Otherwise, the information should be available in the Request.Form collection
[HttpPost]
[ValidateInput(false)]
public ActionResult SendGrid(string from, string to, string text, string subject) //...
{
ProcessEmail(from,to,text,subject...); // your function here
return new EmptyResult();
}
In MVC, you must also set requestValidationMode="2.0" in your web.config or it will still throw on Form Validation.
<system.web>
<httpRuntime requestValidationMode="2.0"/>
</system.web>
精彩评论