本文介绍了如何在MVC中将响应从一个控制器传递到另一个控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为clientjobdescriptionscontroller.cs的控制器。
I have a controller named clientjobdescriptionscontroller.cs.
//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));
}
}
}
我还有另一个名为RequestController的控制器。来自该控制器的方法在第一个控制器中被调用。
again I have another controller named RequestController. The methods from this controller is getting called in the first controller.
// RequestController
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);
}
我的尝试:
我试图将响应作为参数传递,但我抛出错误。
What I have tried:
I have tried to pass the response as parameter but i throws error.
推荐答案
这篇关于如何在MVC中将响应从一个控制器传递到另一个控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!