I have written web api in which it is returning/producing json response. Below is the code for the same.
[HttpGet]
[Route("someapi/myclassdata")]
[Produces("application/json")]
public MyClassData GetMyClassData(int ID, int isdownload)
{
myclassdata = myclassdataBL.GetMyClassData(ID);
return myclassdata;
//**Commented Code**
//if(isdownload==1)
//{
//download file
//}
//else
//{
// send response
//}
}
Till now it is working fine. Now I want to create and download the file based on value in 'isDownload' parameter.
So after getting the data if files needs to be downloaded I want to download the file otherwise I will send the json response.
So, my question is can we send json reponse or download the file in same web api method.
Any help on this appreciated!