Is it possible for a Webforms class to call an MVC2 action controller that returns a string?
My Webforms class is a proxy class for an external webservice, and so I have no JavaScript code - the properties thatI need must be retr开发者_如何学JAVAieved in the code-behind!
The proxy class is in use by other projects in my solution, so I preferably do not want to move it into the MVC project. The proxy gathers a few properties, among them the full path to a PDF.
The PDF has not yet been generated when the proxy needs it, and the responsibility of generating it lies on the MVC project. Because of this, I need to call an action controller that generates a PDF and returns its path.
You shouldn't really mix webforms and MVC. Better to put them in separate apps & communicate via HTTP/REST/SOAP, etc.
If it's an external web service, can you not add it again to your MVC app?
If you can't modify the proxy at all, then add a webforms page to your mvc app & have it inherit from the proxy. create the controller & action to create the pdf the redirect back to the webform.
Simon
The solution that worked for me was to use the WebRequest class, which MSDN has a good article on here: How to: Send Data Using the WebRequest Class
精彩评论