如何将响应从一个控制器传递到另一个控制器?
How to pass Response from one controller to another?
//clientjobdescriptionscontroller.cs
[HttpGet]
public void Download(string format, string requests)
{
List<string> req = requests.Split(',').ToList();
foreach (var item in req)
{
RequestController controller = new RequestController();
if (format == "I")
{
Response.Write("rakesh");
controller.DownloadrequirementsInternalUse(Convert.ToInt64(item));
}
if (format == "R")
{
controller.DownloadrequirementsRecruitmentPartner(Convert.ToInt64(item));
}
if (format == "CA")
{
controller.DownloadrequirementsCandidate(Convert.ToInt64(item));
}
if (format == "CR")
{
controller.Downloadrequirementscustomer(Convert.ToInt64(item));
}
}
}
//请求控制器
public void DownloadrequirementsInternalUse(long Id)
{
var result = requestService.GetResourceAvailability(Id);
JobDescriptionPdfDownload jobDescriptionPdfDownload = new JobDescriptionPdfDownload();
string strOutput = jobDescriptionPdfDownload.DownloadrequirementsInternalUse(Id);
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=JD-Internal-Use-" + result.RequestCode + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
CreatePdf(strOutput);
}
Use your action method like this
public ActionResult Download(string format, string requests)
{
}
尝试在您的控制器中使用操作方法 (return actionresult) 并尝试这个
return RedirectToAction("DownloadrequirementsInternalUse", "RequestController", new { id=Convert.ToInt64(item) });
//clientjobdescriptionscontroller.cs
[HttpGet]
public void Download(string format, string requests)
{
List<string> req = requests.Split(',').ToList();
foreach (var item in req)
{
RequestController controller = new RequestController();
if (format == "I")
{
Response.Write("rakesh");
controller.DownloadrequirementsInternalUse(Convert.ToInt64(item));
}
if (format == "R")
{
controller.DownloadrequirementsRecruitmentPartner(Convert.ToInt64(item));
}
if (format == "CA")
{
controller.DownloadrequirementsCandidate(Convert.ToInt64(item));
}
if (format == "CR")
{
controller.Downloadrequirementscustomer(Convert.ToInt64(item));
}
}
}
//请求控制器
public void DownloadrequirementsInternalUse(long Id)
{
var result = requestService.GetResourceAvailability(Id);
JobDescriptionPdfDownload jobDescriptionPdfDownload = new JobDescriptionPdfDownload();
string strOutput = jobDescriptionPdfDownload.DownloadrequirementsInternalUse(Id);
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=JD-Internal-Use-" + result.RequestCode + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
CreatePdf(strOutput);
}
Use your action method like this
public ActionResult Download(string format, string requests)
{
}
尝试在您的控制器中使用操作方法 (return actionresult) 并尝试这个
return RedirectToAction("DownloadrequirementsInternalUse", "RequestController", new { id=Convert.ToInt64(item) });