作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
http://documentation.mailgun.net/quickstart.html包含 Django 中的 http 处理程序的一些示例代码:
# Handler for HTTP POST to http://myhost.com/messages for the route defined above
def on_incoming_message(request):
if request.method == 'POST':
sender = request.POST.get('sender')
recipient = request.POST.get('recipient')
subject = request.POST.get('subject', '')
body_plain = request.POST.get('body-plain', '')
body_without_quotes = request.POST.get('stripped-text', '')
# note: other MIME headers are also posted here...
# attachments:
for key in request.FILES:
file = request.FILES[key]
# do something with the file
# Returned text is ignored but HTTP status code matters:
# Mailgun wants to see 2xx, otherwise it will make another attempt in 5 minutes
return HttpResponse('OK')
ASP.NET C# 中的等价物是什么?
例如,我已经尝试过 Request.Form["sender"],但是 Mailgun 日志记录了一个 HTTP 500 错误代码。
感谢您的帮助。
最佳答案
主要我希望我能在大约 6 小时前找到这个......
如果您使用 mvc 和 razor View 引擎,则需要执行以下操作
[HttpPost]
[ValidateInput(false)]
public ActionResult GoTruckGo(FormCollection oColl)
{
try
{
string sender = Request.Unvalidated().Form["sender"];
string body = Request.Unvalidated().Form["body-plain"];
sendLog(body);
// do something with data
}
catch (Exception ex)
{
sendLog("entered catch = "+ ex.Message);
}
return Content("ok");
}
关于c# - 如何在 ASP.NET C# 中从 Mailgun 接收 HTTP POST?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8481325/
我是一名优秀的程序员,十分优秀!