<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Custom Security Extension using Forms Authentication sending invalid URI on redirect in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Security-Extension-using-Forms-Authentication-sending/m-p/4633802#M60146</link>
    <description>&lt;P&gt;I had a new server created in our dev environment with Windows Server 2022 Datacenter as the OS and PowerBI Server installed.&amp;nbsp; I was able to recreate the issue on that server.&amp;nbsp; It seems to be an issue with Windows Server 2022 Datacenter rejecting the invalid URL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also installed .NET Core 6 on the server and the issue remained, so it does not seem to be related to the .NET Framework or .NET Core versions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm going to try to figure out if I can manipulate the URL before PowerBI sends it to the browser so that I can encode the extra '?'.&amp;nbsp; Not sure how to do that yet, if it is even possible.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Apr 2025 18:39:25 GMT</pubDate>
    <dc:creator>abeckham7305</dc:creator>
    <dc:date>2025-04-01T18:39:25Z</dc:date>
    <item>
      <title>Custom Security Extension using Forms Authentication sending invalid URI on redirect</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Security-Extension-using-Forms-Authentication-sending/m-p/4631834#M60121</link>
      <description>&lt;P&gt;I implemented a custom security extension for PowerBI server using the sample provided at&amp;nbsp;&lt;A href="https://github.com/microsoft/Reporting-Services/blob/master/CustomSecuritySample" target="_blank" rel="noopener"&gt;https://github.com/microsoft/Reporting-Services/blob/master/CustomSecuritySample&lt;/A&gt;.&amp;nbsp; I updated the Logon Page_Load to redirect to an OIDC provider for authentication.&amp;nbsp; Everything works fine in my local environment.&amp;nbsp; It also works fine on one of our dev servers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We created a new environment to match the Production environment where we are hoping to deploy.&amp;nbsp; It is not work there.&amp;nbsp; The issue I found is that the URI sent from PowerBI to the Logon.aspx page in my custom security extension is not formatted correctly.&amp;nbsp; To be specific, there are two query strings in it.&amp;nbsp; Here is an example of the URI:&lt;/P&gt;&lt;P&gt;&lt;A href="https://az-cs-cybark03.cscustomad1.com:9082/ReportServer/logon.aspx?ReturnUrl=/ReportServer/localredirect?url=%252fReports%252fbrowse" target="_blank" rel="noopener"&gt;https://pbi.prod-server.com/ReportServer/logon.aspx?ReturnUrl=/ReportServer/localredirect?url=%252fReports%252fbrowse&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice after the logon.aspx there is a ? to start the query string, then after localredirect there is another ? to seemingly start a second query string, which is invalid for a URI.&amp;nbsp; I understand the purpose of the second query string.&amp;nbsp; It is supposed to be apart of the 'ReturnUrl', but I would think that is should be encoded then.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know why this works locally and in our dev environment.&amp;nbsp; Locally I'm using Windows 11 as my OS.&amp;nbsp; Our dev environment is using&amp;nbsp;Windows Server 2019 Datacenter.&amp;nbsp; Our simulated Prod environment is using&amp;nbsp;Windows Server 2022 Datacenter.&amp;nbsp; I'm check now to see if that has any impact.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts on how I can get this to work?&amp;nbsp; Since the URI is coming from PowerBI I'm not able to manipulate it in my custom Logon page.&amp;nbsp; Maybe there is a setting in the web.config to tell it to encode the ? in the ReturnUrl.&amp;nbsp; Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 16:33:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Security-Extension-using-Forms-Authentication-sending/m-p/4631834#M60121</guid>
      <dc:creator>abeckham7305</dc:creator>
      <dc:date>2025-03-31T16:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Security Extension using Forms Authentication sending invalid URI on redirect</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Security-Extension-using-Forms-Authentication-sending/m-p/4632558#M60130</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1249755"&gt;@abeckham7305&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for reaching out to Microsoft Fabric Community Forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please check if the Windows Server 2022 environment has a different version of .NET installed compared to the Dev environment. Sometimes, different .NET versions handle URL encoding differently, which could be causing the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Vinay Pabbu&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 06:42:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Security-Extension-using-Forms-Authentication-sending/m-p/4632558#M60130</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-04-01T06:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Security Extension using Forms Authentication sending invalid URI on redirect</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Security-Extension-using-Forms-Authentication-sending/m-p/4633610#M60142</link>
      <description>&lt;P&gt;Thanks for the suggestion Vinay!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I checked the versions of .NET Framework, which is needed to run PowerBI, and they match across both servers.&amp;nbsp; Both are using 4.8.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know if it matters, but the dev server that works has both .NET 6 Core and .NET 8 Core installed on it.&amp;nbsp; The 'Prod' server only has .NET 8 Core.&amp;nbsp; I've been focusing mainly on .NET Framework because of PowerBI.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you think the .NET Core versions could matter for this?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 15:17:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Security-Extension-using-Forms-Authentication-sending/m-p/4633610#M60142</guid>
      <dc:creator>abeckham7305</dc:creator>
      <dc:date>2025-04-01T15:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Security Extension using Forms Authentication sending invalid URI on redirect</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Security-Extension-using-Forms-Authentication-sending/m-p/4633802#M60146</link>
      <description>&lt;P&gt;I had a new server created in our dev environment with Windows Server 2022 Datacenter as the OS and PowerBI Server installed.&amp;nbsp; I was able to recreate the issue on that server.&amp;nbsp; It seems to be an issue with Windows Server 2022 Datacenter rejecting the invalid URL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also installed .NET Core 6 on the server and the issue remained, so it does not seem to be related to the .NET Framework or .NET Core versions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm going to try to figure out if I can manipulate the URL before PowerBI sends it to the browser so that I can encode the extra '?'.&amp;nbsp; Not sure how to do that yet, if it is even possible.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 18:39:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Security-Extension-using-Forms-Authentication-sending/m-p/4633802#M60146</guid>
      <dc:creator>abeckham7305</dc:creator>
      <dc:date>2025-04-01T18:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Security Extension using Forms Authentication sending invalid URI on redirect</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Security-Extension-using-Forms-Authentication-sending/m-p/4638780#M60219</link>
      <description>&lt;P&gt;I figured out a solution.&amp;nbsp; It's more of a workaround though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I learned, without any specific details, that Windows Server 2022 datacenter has much more restrictive policies around URL validation and allowable query strings.&amp;nbsp; My custom extension only needs the query string in order to determine where to redirect the user back to PowerBI once they are authenticated.&amp;nbsp; Instead of trying to capture this in my Page_Load method, I moved that code to the OnInit method at the very beginning.&amp;nbsp; I first check for the ReturnUrl parameter and if present I capture the url parameter from it into a cookie and then immediately redirect to my Logon.aspx page again without any query string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example of the code:&lt;/P&gt;&lt;P&gt;override protected void OnInit(EventArgs e)&lt;BR /&gt;{&lt;BR /&gt;var uri = new Uri(HttpContext.Current.Request.Url.AbsoluteUri);&lt;BR /&gt;var returnUrl = HttpUtility.ParseQueryString(uri.Query).Get("ReturnUrl");&lt;BR /&gt;if (returnUrl != null)&lt;BR /&gt;{&lt;BR /&gt;var returnUri = new Uri("&lt;A href="https://dummy.com" target="_blank"&gt;https://dummy.com&lt;/A&gt;" + returnUrl);&lt;BR /&gt;var encodedRedirectUrl = returnUri != null ? HttpUtility.ParseQueryString(returnUri.Query).Get("url") : null;&lt;BR /&gt;var decodedRedirectUrl = encodedRedirectUrl != null ? HttpUtility.UrlDecode(encodedRedirectUrl) : null;&lt;BR /&gt;if (decodedRedirectUrl != null)&lt;BR /&gt;{&lt;BR /&gt;var redirectUrlCookie = new HttpCookie("redirectUrl", decodedRedirectUrl)&lt;BR /&gt;{&lt;BR /&gt;HttpOnly = true,&lt;BR /&gt;Secure = true&lt;BR /&gt;};&lt;BR /&gt;Response.Cookies.Add(redirectUrlCookie);&lt;BR /&gt;}&lt;BR /&gt;string urlWithoutQueryString = uri.GetLeftPart(UriPartial.Path);&lt;BR /&gt;HttpContext.Current.Response.Redirect(urlWithoutQueryString);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;InitializeComponent();&lt;BR /&gt;base.OnInit(e);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This manages to remove the query string from the URL that PowerBI is providing before the Windows Server 2022 restrictions apply to it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now my custom extension works on both Windows Server 2019 and 2022.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 18:26:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Security-Extension-using-Forms-Authentication-sending/m-p/4638780#M60219</guid>
      <dc:creator>abeckham7305</dc:creator>
      <dc:date>2025-04-04T18:26:20Z</dc:date>
    </item>
  </channel>
</rss>

