how to render view from online template in asp.net mvc project?



  • i made a template in online jsreport server.
    I am going to use this template in a controller as view.
    I can render that template by using RenderByNameAsync.
    but how can I return as ActionResult type?
    I am going to get rendered html as result.
    anyone help me?



  • I probably miss something, but this looks like a trivial thing to return a stream from the mvc controller action.

    return new FileStreamResult(reporter.Content, "application/pdf")
    


  • thank you for your comment.
    I wrote following code in async action.
    public async Task<ContentResult> ReportTotalMonthlyValueAsync(TMVReportViewModel viewModel)
    {
    rs = new ReportingService("https://jsreport-cpro.azurewebsites.net/", "user", "password");
    var report = await rs.RenderByNameAsync("TotalMonthlyValueReport", new
    {
    viewModel.TotalSubscriptionFee,
    viewModel.TotalBillableFee,
    viewModel.totalProcessingRevenueOnPremFee,
    viewModel.TotalBillableUserCountFee,
    viewModel.totalAllRevenue
    });
    string text;
    using (StreamReader reader = new StreamReader(report.Content))
    {
    text = reader.ReadToEnd();
    }
    return Content(text);
    }

    when call rs.RenderByNameAsync function, this function does not return.
    so i implemented it in console app and it does work.
    it only does not work in mvc action.
    could you help me?


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.