1
저는 Visual Studio에 임베디드 BI를 사용하여 앱을 제작하고 있습니다. 내가 포함하려는 실제 보고서의 사용자 이름과 역할에 해당하는 컨트롤러의 보고서 작업에 사용자 이름과 역할을 추가했습니다. index.cshtml의 텍스트 상자에서 Report 액션으로 사용자 이름을 변수로 전달하려고합니다. 이 값이 하드 코드되면 보고서가로드되고 삽입되지만 변수로 전달할 수 없습니다. 여기 MVC Power BI Embedded를 사용하여 변수를 전달하는 방법은 무엇입니까?
컨트롤러의 ActionResult입니다 - 모델에서public async Task<ActionResult> Report(string reportId)
{
//This is where I'm trying to get the variable from the textbox
username = Request["centreID"].ToString();
using (var client = this.CreatePowerBIClient())
{
var reportsResponse = await client.Reports.GetReportsAsync(this.workspaceCollection, this.workspaceId);
var report = reportsResponse.Value.FirstOrDefault(r => r.Id == reportId);
IEnumerable<string> roles = new List<string>() { "xxxxxxxx" };
// I can hardcode the username here, and it works, but can't pass in a variable from the html like above
//string username = "xxxxxx";
//username = this.username;
var embedToken = PowerBIToken.CreateReportEmbedToken(this.workspaceCollection, this.workspaceId, report.Id, username, roles);
var viewModel = new ReportViewModel
{
Report = report,
AccessToken = embedToken.Generate(this.accessKey)
};
return View(viewModel);
}
}
내가 내 GET을 넣고 여기에
public string username { get; set; }
내가 사용했던 HTML입니다 설정 한 곳이다; 내가 전에 컨트롤러의 빈 공간 방법으로이 테스트를했는데 그것은
@using (Html.BeginForm("Report", "Dashboard"))
{
@Html.Label("Enter Centre ID")
@Html.TextBox("centreID")
<input type="submit" value="submit" />
}
</span>
</a>
이 줄의 중단 점'username = Request [ "centreID"]. ToString();'... 값을 얻었습니까? – Hackerman
아니요 ... 컨트롤러의 void 메쏘드를 가리키는 html.beginform 액션이 생기기 전에, 다음에는 중단 점을 넣었고 그 값을 전달하고있었습니다. 이것은 비동기식이기 때문입니까? –
그리고 'reportId' 값은? – Hackerman