<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[HttpContext.JsReportFeature() returns null]]></title><description><![CDATA[<p>Hello,<br />
I am trying jsreport in <a href="http://ASP.NET" rel="nofollow">ASP.NET</a> Core 2.1 Razor pages. I am following the example given at<br />
<a href="https://github.com/jsreport/jsreport-dotnet-example-webapp/blob/master/Controllers/HomeController.cs#L26" rel="nofollow">https://github.com/jsreport/jsreport-dotnet-example-webapp/blob/master/Controllers/HomeController.cs#L26</a>.</p>
<p>I have a similar method on my Razor Page</p>
<p>public class IndexModel : PageModel<br />
{<br />
public void OnGet()<br />
{</p>
<pre><code>    }

    [MiddlewareFilter(typeof(JsReportPipeline))]
    public IActionResult OnPostGeneratePdf()
    {
        
        HttpContext.JsReportFeature().Recipe(Recipe.PhantomPdf);
        return Page();
    }
}
</code></pre>
<p>The problem is that HttpContext.JsReportFeature() is null and I get an object reference error. I already added the required code in startup.cs.</p>
<p>The sample app provided at <a href="https://github.com/jsreport/jsreport-dotnet-example-webapp" rel="nofollow">https://github.com/jsreport/jsreport-dotnet-example-webapp</a> runs perfectly fine locally. The only difference is that the sample app is MVC based with Model-View-Controllers whereas I am using the Razor Pages.</p>
<p>Appreciate any help on this.<br />
Thank you</p>
]]></description><link>https://forum.jsreport.net/topic/692/httpcontext-jsreportfeature-returns-null</link><generator>RSS for Node</generator><lastBuildDate>Mon, 12 Oct 2026 09:54:11 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/692.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 03 Sep 2018 00:19:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to HttpContext.JsReportFeature() returns null on Invalid Date]]></title><description><![CDATA[<p>Hello,<br />
I am trying jsreport in <a href="http://ASP.NET" rel="nofollow">ASP.NET</a> Core 2.1 Razor pages. I am following the example given at<br />
<a href="https://github.com/jsreport/jsreport-dotnet-example-webapp/blob/master/Controllers/HomeController.cs#L26" rel="nofollow">https://github.com/jsreport/jsreport-dotnet-example-webapp/blob/master/Controllers/HomeController.cs#L26</a>.</p>
<p>I have a similar method on my Razor Page</p>
<p>public class IndexModel : PageModel<br />
{<br />
public void OnGet()<br />
{</p>
<pre><code>    }

    [MiddlewareFilter(typeof(JsReportPipeline))]
    public IActionResult OnPostGeneratePdf()
    {
        
        HttpContext.JsReportFeature().Recipe(Recipe.PhantomPdf);
        return Page();
    }
}
</code></pre>
<p>The problem is that HttpContext.JsReportFeature() is null and I get an object reference error. I already added the required code in startup.cs.</p>
<p>The sample app provided at <a href="https://github.com/jsreport/jsreport-dotnet-example-webapp" rel="nofollow">https://github.com/jsreport/jsreport-dotnet-example-webapp</a> runs perfectly fine locally. The only difference is that the sample app is MVC based with Model-View-Controllers whereas I am using the Razor Pages.</p>
<p>Appreciate any help on this.<br />
Thank you</p>
]]></description><link>https://forum.jsreport.net/post/3427</link><guid isPermaLink="true">https://forum.jsreport.net/post/3427</guid><dc:creator><![CDATA[Kapil Kumar]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to HttpContext.JsReportFeature() returns null on Invalid Date]]></title><description><![CDATA[<p>You can try to debug it<br />
<a href="https://github.com/jsreport/jsreport-dotnet-aspnetcore/blob/master/jsreport.AspNetCore/JsReportMiddleware.cs#L21" rel="nofollow">https://github.com/jsreport/jsreport-dotnet-aspnetcore/blob/master/jsreport.AspNetCore/JsReportMiddleware.cs#L21</a></p>
<p>However I am afraid MiddlewareFilter is not invoked in razor pages.</p>
]]></description><link>https://forum.jsreport.net/post/3433</link><guid isPermaLink="true">https://forum.jsreport.net/post/3433</guid><dc:creator><![CDATA[jan_blaha]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to HttpContext.JsReportFeature() returns null on Mon, 03 Sep 2018 16:36:52 GMT]]></title><description><![CDATA[<p>If MiddlewareFilter is not invoked probably that is the reason.<br />
Does that mean, I cannot generate for e.g. pdf reports if I am using Razor Pages? Does jsreport only work on MVC projects?</p>
]]></description><link>https://forum.jsreport.net/post/3434</link><guid isPermaLink="true">https://forum.jsreport.net/post/3434</guid><dc:creator><![CDATA[Kapil Kumar]]></dc:creator><pubDate>Mon, 03 Sep 2018 16:36:52 GMT</pubDate></item><item><title><![CDATA[Reply to HttpContext.JsReportFeature() returns null on Invalid Date]]></title><description><![CDATA[<p>I don't know. There is likely a way how to get html string from the razor page which you can afterwards easily convert into pdf using jsreport.<br />
Unfortunately I am too busy to investigate this and I never used razor pages before.</p>
<p>If you find out how to get the html string form the razor page, you can use this code to convert it to the pdf.</p>
<pre><code class="language-csharp">var rs = new LocalReporting().UseBinary(JsReportBinary.GetBinary()).AsUtility().Create();

var report = await rs.RenderAsync(new RenderRequest()
{
    Template = new Template()
    {
        Recipe = Recipe.PhantomPdf,
        Engine = Engine.None,
        Content = &quot;The html you get from the razor page&quot;
    }
});
</code></pre>
]]></description><link>https://forum.jsreport.net/post/3444</link><guid isPermaLink="true">https://forum.jsreport.net/post/3444</guid><dc:creator><![CDATA[jan_blaha]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>