在 WCF 中你有这样的东西
[ServiceContract]
public interface IDoAuditService
{
[OperationContract(IsOneWay = true)]
[WebInvoke]
void Audit(AuditEntry auditEntry);
}
这将允许消费者发出请求并继续流程,而无需等待响应。
我尝试过使用 AsyncController 的 Asp.net MVC,但消费者仍然会阻塞并等待,直到在 Controller 中调用回调。
我想要的是使用 Asp.Net MVC 但行为 WCF 就像,我想发出请求并继续流程而不等待请求被处理
最佳答案
在服务器上异步执行操作主体并立即返回调用者怎么样?这并不完全是一劳永逸,但它会效仿这一点。
public ActionResult MyAction()
{
var workingThread = new Thread(OperationToCallAsync);
workingThread.Start();
return View();
}
void OperationToCallAsync()
{
...
}
关于asp.net - 如何像WCF一样实现Asp.net MVC One Way/Fire And Forget调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11121915/