I successfully implemented a WCF service (with wsDualHttpBinding) in MVC.
"SendResult" function get correctly called from WCF and receives the results in the "Events_For_Export_Result" array. Now I should redirect MVC to a controller/view to show a message, but I cannot invoke an action in the call back function.
As you can see below, I tried to make my callback class inherits from "Controller" and invoked a function that perform a "RedirectToAction", but it does not work.
What I am doing wrong? Is there a way to invoke an action in a void method?
public class GPWCFServiceCallBackController : Controller, IGPWCFServiceCallback
{
public void SendResult(GPWCFService.Events_For_Export_Result[] arrEvents, string resultMessage)
{
ShowResult(arrEvents, resultMessage);
}
public ActionResult ShowResult(GPWCFService.Events_For_Export_Result[] arrEvents, string resultMessage)
{
return RedirectToAction("Index", "Home");
}
}
I think it has something to do with the nature of the wsDualHttpBinding. In fact, I cannot change the return type of the function, since I have to specify [OperationContract(IsOneWay = true)] attribute. In this way, the callback function must be void.
This is the callback interface:
/// <summary>
/// The Callback Interface
/// </summary>
public interface IGPWCFServiceCallback
{
[OperationContract(IsOneWay = true)]
void SendResult(Events_For_Export_Result[] arrEvents, string resultMessage);
}
Your controller class name should ending with word Controller
Look at this question .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.