I am using the MVC app as a service, so i have deleted the views. I am able to make calls to the controller:
public class HomeController : Controller
{
// GET: /Home/
public string Index(string param1, string param2) {
...
}
from the MFC app:
string URL(_T("http://localhost:2374/home/index/myparam1/myparam2"));
pHttpFile = dynamic_cast<CHttpFile*> (m_Session.OpenURL(URL));
if (pHttpFile) {
CHAR szBuff[1024] = { 0 };
while (pHttpFile->Read(szBuff, 1024) > 0) {
info += szBuff;
...
Now to upload an XML file, i am trying this on the MFC client:
CHttpConnection *pHttpConn = m_Session.GetHttpConnection(_T("localhost:2374"));
if (pHttpConn)
{
CHttpFile *pHttpFile = pHttpConn->OpenRequest(
CHttpConnection::HTTP_VERB_POST,
_T("file.xml"));
DWORD dwRet = 0;
pHttpFile->QueryInfoStatusCode(dwRet);
if (dwRet == HTTP_STATUS_OK)
{
CString headers(_T("Content-type: text/xml; charset=utf-8"));
if (pHttpFile->AddRequestHeaders(headers))
{
if (pHttpFile->SendRequestEx(xml.GetLength(), HSR_SYNC | HSR_INITIATE))
{
pHttpFile->Write(xml, xml.GetLength());
pHttpFile->EndRequest(HSR_SYNC);
...
and this on the MVC side:
[AcceptVerbs(HttpVerbs.Post)]
public void FileUpload(HttpPostedFileBase uploadFile)
{
The client executes without error, but nothing happens on server side. I am not sure how to get FileUpload() called in the Controller. Do i use MapRoute(), if so how?