2014-04-03 3 views
3

서버 보고서와 MVC 컨트롤러 동작 - Index으로 리디렉션하는 단추를 사용하는 ReportViewer 인 웹 폼 (.aspx 페이지)이 있습니다. 서버 보고서 매개 변수를 컨트롤러 동작에 전달하고 싶습니다. 가능한가? ActionResult가 아니라 일반적으로 보이는WebForm에서 Response.Redirect에 의해 MVC 컨트롤러에 매개 변수 전달

protected void Button1_Click(object sender, EventArgs e) 
{ 
    List<ReportParameterInfo> param = ReportViewer1.ServerReport.GetParameters().ToList(); 
    string month = param.Where(p => p.Name == "month").FirstOrDefault().Values.FirstOrDefault(); 
    string year = param.Where(p => p.Name == "year").FirstOrDefault().Values.FirstOrDefault(); 

    Response.Redirect("/Report/"); 
} 

내 인덱스 :

public ActionResult Index() 
    { 
      .... 
      return View(); //returns .cshtml view 
    } 

내가 어떤 조언을 감사하겠습니다

그래서, 나는 PARAMS를 얻을.

+0

조치가 매개 변수를 필요로하지 않는 것으로 보입니다. – Andrei

답변

3

쿼리 문자열을 통해 전달하고 MVC의 모델 바인더를 사용할 수 있습니다.

웹 양식 앱에서 Response.Redirect("/Report/?Year=2014&Month=2");을 사용하십시오. 그런 다음 작업에 매개 변수를 추가하십시오.

public ActionResult Index(int year, int month) 
{ 
    // year and month will be populated with the query string values 
    return View(); //returns .cshtml view 
}