Embedding RS reports, HighCharts, and PBI interactives in ASP.NET Core MVC views


SSRS embed
 @model ReportView  
 <script>  
 </script>  
 <div class="container" style="background-color:#ffffff">  
   <section>  
     <div style="background-color:#ffffff; box-shadow: 5px 10px 8px #888888;">  
       <iframe height="800" width="900" src="@Model.SelectedReport.Uri" class="body-box-shadow"></iframe>  
     </div>  
   </section>  
 </div>  
This is the entire view of _Report.cshtml which renders the RS report; see the extRSAuth project for how to enable non-Windows AD SSRS client authentication



The <iframe> is rendered with the URL of the report on your report server which renders a ReportViewer control view of the report



HighCharts embed
 <script src="https://code.highcharts.com/highcharts.js"></script>  
 <script src="https://code.highcharts.com/themes/adaptive.js"></script>  
 <head>  
   <script>  
     $(document).ready(function () {  
       Highcharts.seriesTypes.line.prototype.getPointSpline = Highcharts.seriesTypes.spline.prototype.getPointSpline;  
       Highcharts.chart('potusApproval', {  
       title: {  
         text: 'Trump Job Approval',  
         align: 'left'  
       },  
       subtitle: {  
           text: 'Source: <a href="https://api.votehub.com/polls?poll_type=approval&subject=Trump" target="_blank">VoteHub</a>.',  
         align: 'left'  
       },  
       yAxis: {  
         title: {  
           text: 'Approval'  
         }  
       },  
       legend: {  
         layout: 'vertical',  
         align: 'right',  
         verticalAlign: 'middle'  
       },  
       plotOptions: {  
             area: {  
               pointStart: '1/1/2025',  
               relativeXValue: false,  
               marker: {  
                 enabled: true,  
                 symbol: 'circle',  
                 radius: 2,  
                 states: {  
                   hover: {  
                     enabled: true  
                   }  
                 }  
               }  
             }  
           },  
       series: [{  
         name: 'Approve',  
         data: [ @string.Join(", ", Model.HighChartsModel.Approves) ]  
       }, {  
         name: 'Disapprove',  
         data: [ @string.Join(", ", Model.HighChartsModel.Disapproves) ]  
       }],  
     });  
   });  
   </script>  
 </head>  
 <table style="width: 100%; height:50%">  
   <tr><td><div id="potusApproval"></div></td></tr>  
 </table>  
The same data can easily be embedded as a HighCharts visual using some JS and HTML; this example uses the simple HighCharts LineChart


The above HighCharts embed code renders this line chart



Power BI embed


The easiest Power BI embedded method is to use the Developer Playground "demo code" script; select File >> Developer Playground



Next, click the "Set up now" button on the upper right side of the following screen




Here you are presented with the embed <iframe> script that you put into your view... 



 <iframe title="PBI_Report" style="width:100%; height:73%" src="https://app.powerbi.com/reportEmbed?reportId=695fe0f1-5c9e-497d-8913-e59f0b939ac4&autoAuth=true&embeddedDemo=true" frameborder="0" allowFullScreen="true"></iframe>  



And, voila! You have a Power BI visual embedded inside your web app now



Reference: https://learn.microsoft.com/en-us/power-bi/developer/

Source: https://github.com/sonrai-LLC/extRS/tree/main/ExtRS.Portal | https://extrs.net


SQL Server 2025's sp_invoke_external_rest_endpoint with OPENJSON CTE for quickly and easily getting data from REST APIs

SQL Server 2025 introduces a convenient way to get data from a REST API endpoint directly through T-SQL and SQL Server utilities.


Outlined in lime green are the two items SQL Server 2025 handles well, discussed in this post


Prior ways of doing this usually involved using MSXML2.XMLHTTP (a COM object provided by Microsoft XML Core Services) through extended stored procedures, but with MSSQL 2025, there is a new SP, sp_invoke_external_rest_endpoint that is very readable and easy to use to get JSON (or XML) from an API response.

This brief article describes what an SP to get this data may look like, as well as the code to parse the JSON in the response to format the result as a table (vs. sending back all the JSON for the client to parse).

Here is an SP which fetches polling data for the Approval Polling data on current U.S. president Donald Trump:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:	colin fitzgerald
-- Create date: 20250625
-- Description: SP to fetch data from VoteHub API
-- =============================================
CREATE OR ALTER PROCEDURE dbo.sp_GetVoteHubPollingData
	@LongView BIT = 0
AS
BEGIN
SET NOCOUNT ON;

EXECUTE sp_configure 'external rest endpoint enabled', 1;
RECONFIGURE WITH OVERRIDE;

DECLARE @ret AS INT, @response AS NVARCHAR (MAX);

EXECUTE
    @ret = sp_invoke_external_rest_endpoint
    @url = N'https://api.votehub.com/polls?poll_type=approval&subject=Trump',
    @headers = N'{"Accept":"application/json"}',
    @method = 'GET',
    @response = @response OUTPUT;

;WITH ResponseContent AS
(SELECT [key], [value] FROM OPENJSON(@response)),
 ResponseJson AS
(SELECT [value] FROM OPENJSON((SELECT [value] FROM ResponseContent WHERE [key]='result')))

SELECT --value,
--id,
pollster,
[subject],
poll_type,
sample_size,
created_at, 
approve,
disapprove
FROM ResponseJson
OUTER APPLY OPENJSON(value) WITH(
  id nvarchar(255), 
  pollster nvarchar(255),
  [subject] nvarchar(255),
  poll_type nvarchar(255), 
  sample_size int, 
  created_at datetime,
  approve decimal '$.answers[0].pct',
  disapprove decimal '$.answers[1].pct'
)
WHERE created_at >= CASE WHEN @LongView = 0 THEN dateadd(mm, -3, getDate()) ELSE created_at END 
ORDER BY created_at DESC

EXECUTE sp_configure 'external rest endpoint enabled', 0;
RECONFIGURE WITH OVERRIDE;

END
GO


And here is the design view of the data source for a report using this polling table data:



And here is the design view of the report that will use this data:



If we CREATE dbo.sp_GetVoteHubPollingData as stored procedure on a database (in this case, I created it in 'master') that our data source connects to, then we can deploy the report to a Report Server or Power BI Report Server and run it:


This is the report as rendered within Power BI Report Server's Portal using extRSAuth for authentication and authorization





This is the report as rendered within extRSAuth custom PBIRS reporting portal on extrs.net 



Lots of neat stuff you can do with the new features of SQL Server 2025- check 'em out.

Next up: embedding a PBI version of this report in extrs.net, and embedding a HighCharts JS version of this report in extrs.net- all using this dbo.sp_GetVoteHubPollingData SP that uses sp_invoke_external_rest_endpoint.


References:

https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-invoke-external-rest-endpoint-transact-sql

https://learn.microsoft.com/en-us/sql/relational-databases/json/convert-json-data-to-rows-and-columns-with-openjson-sql-server

Customizing ASP.NET Core Identity Razor Pages via Scaffolding (in an MVC app)

If you are trying to add the built-in ASP.NET Core Identity Authentication scaffolding to an MVC application, you will notice that traversing between MVC controller actions and simple requests to Razor Pages doesn't work as transparently as you might expect.

To scaffold the Identity Razor Pages so that we can customize them, we first do the following:

Right-click the project and select, "Add >> New Scaffolded Item..."


Select the Identity scaffolding template


From the next screen, select the Razor pages that you would like to scaffold for overriding/customizing


Once you have the scaffolded pages you will need to run this from the Developer console to generate the necessary ASP.NET Core Identity database tables: dotnet ef database update

If you want to be able to get to the Login page from an MVC controller, you will; need to an [AllowAnonymous] attribute to the Login.cshtml Razor Page code-behind class, and you will need to call the Login page while referencing the Area path in which it is located within the project file structure.

The folder structure for an MVC project overriding the built-in Identity auth Razor pages via scaffolding


An MVC logout link that you want to redirect to an overridden Identity auth Login Razor page might look like this in your _Layout view: 

The view link in the MVC's _Layout.cshtml

The controller redirect (note: new { area = "Identity" }); "/Pages/" is ignored for some reason..

In order to reach the Login Razor page (when not being authenticated) you will need to add the [AllowAnonymous] attribute to the LoginModel class a la:

With [AllowAnonymous] users will be able to reach the overridden Identity Login page from any controller action in your MVC application


An that's it. You can customize all of the front-end and back-end code of the scaffolded Identity Razor pages. This is an example of customization that uses the extRS service to create SSRS user accounts when a user registers a new Identity account for the app:

Scaffolding the Identity Razor pages allows you focus only on the authentication design and logic that you need to customize 


I'm not sure why but much of this is not documented (and what is documented is not easily found).

Lastly, do keep in mind that in order to override certain items like "_LoginPartial", you need to rename the view, as was done with "_LoginPartial2.cshtml" in the extRS project, for example.


References: 

https://github.com/sonrai-LLC/extRS/tree/main/ExtRS.Portal

https://extrs.net




    

    

Implement extRSAuth on SSRS v16.0, SQL Server 2025


This short YouTube demonstration covers e2e implementation, from GitHub to your machine


extRSAuth is tested to work with traditional SQL Server Report Server and the new Power BI Report Server



GitHub: https://github.com/sonrai-LLC/extRSAuth

Asset Classes

Assets Classes are "a group of marketable financial assets that have similar financial characteristics and behave similarly in the marketplace". They represent the different types of (usually) tangible things that can be owned and be assessed a "valuation".


Public Stocks (Equities) - shares of ownership in publicly-held companies 

  • Stocks are listed on stock exchanges which are open to the public investment
  • Historically, have outperformed other investments over long periods
  • Most volatile in the short term
  • Returns and principal for a stock fluctuate over time, making funds from the eventual sale of the stock worth more or less than original cost (depends on the stock purchase price)

Private Equity (Private Stocks)shares of ownership in privately-held and unlisted companies

  • Typically, only a few large investors
  • Usually focuses on short-term capital extraction and "sale for parts"
  • Often financed by leveraged buyouts (loading the target company with new debt to help the PE firm fund the acquisition of the target company)
  • Can be designed to turn around the fortunes/profitability of a distressed company by cutting costs, replacing management and changing company direction; in this case the investment is more long-term, but ultimately the goal of PE is to extract a large profit from the sale of the acquired company once its profitability (and thus valuation) has improved
  • A "property flip" is a minor/small-scale form of PE


Bonds/Notes/Bills (Fixed Income) - guaranteed bond investments

  • Pays a set rate of interest over a given period, then return the investor's principal
  • More stability than stocks
  • Value fluctuates due to current interest and inflation rates
  • Includes "guaranteed" or "risk-free" assets
  • Also includes money market instruments (short-term fixed income investments)
  • Often comprised of federal government or municipal bonds, notes or bills
  • Can also include corporate loans
  • The term used to describe this type of debt asset ("bond/note/bill") depends on the length of the debt instrument maturity, with "bonds" typically being a maturity of 10-20 years, "notes" being a maturity of 1-10 years and "bills" (like T-Bills) being a maturity of less than 1 year


Cash and Equivalents (Liquid Assets) - assets that can be quickly and easily converted into immediately usable currency without losing significant value

  • Checking and savings accounts
  • Certificates of deposit (CDs)
  • Money market funds
  • Treasury bills
  • Treasury notes
  • Commercial paper
  • Foreign currencies which are easily convertible to the currency you need to transact in
  • Liquid assets have the advantage of giving their owner the power to buy things without incurring any debt

Cryptocurrency - a "piece" of (usually limited) digital currency

  • The backbone of "DeFi" or Decentralized Finance
  • "Digital rare earth material"
  • Relatively accessible; mineable and tradable
  • "Risk-on" asset; lacks regulation, ESG concerns, highly volatile
  • Liquidity has increased with institutional adoption
  • Supply varies, some are finite or even designed to shrink in supply and thus deflationary
  • No inherent value or utility (like NFTs)
  • But(!), cryptocurrency underlies the transactional architecture of a bulk of all untraced, "black market" commercial activity worldwide
  • Barring meaningful cryptocurrency regulation, its value is unlikely to ever "go to zero" or not hold some significant value because of its usefulness in facilitating illegal monetary transactions and digital money laundering


Recently, interest in stocks and crypto has spiked while interest in bonds and private equity has remained more muted and stable


Real Estate - investment property (houses, stores, factories, land lots, etc.) and commercial real estate investments

  • Helps protect future purchasing power as property values typically rise with inflation
  • Values tend to rise and fall more slowly than stock and bond prices.
  • It is important to keep in mind that the real estate sector is subject to various risks, including fluctuation in underlying property values, interest rates (which directly influence mortgage rates, which usually compose a large part of any real estate purchase), eminent domain law, and potential environmental liabilities
  • Can include "Infrastructure as an asset class"- a broad category including highways, airports, rail networks, energy generation (utilities), energy storage and distribution (gas mains, pipelines etc.)
  • Can provide a long-term cash flow, a hedge against inflation, and diversification (low correlation with the top two traditional asset classes: equity and fixed income)


Commodities - physical goods such as gold, copper, crude oil, natural gas, wheat, corn and electricity

  • Can serve both as a value store in and of itself (in the case of things that don't expire, like precious metals) and as raw material for the construction and delivery of downstream physical goods and services
  • Helps protect future purchasing power as commodity values rise with inflation
  • Values tend to have low correlation with stock and bond prices
  • Price dynamics are unique: commodities become more volatile as prices rise

Interest in CRE and commodities has fallen precipitously since 2004...




References:

https://www.thrivent.com/insights/investing/an-investors-guide-to-asset-classes-types-allocations-more

https://www.poems.com.sg/glossary/investment/asset-class/

https://cointelegraph.com/learn/overview-of-different-types-of-asset-classes

https://en.wikipedia.org/wiki/Asset_classes