Monday, December 29, 2025

Upgrading Maui Code to .NET 10 - MainPage

 I've got a project that I keep around to do all of the .NET Maui stuff that I need to do.  It is currently in .NET 8/9 (I'm not sure which).  I'm starting to upgrade it to .NET 10.  I have a lot of warnings of code that is found to be obsolete.  I'm going to document for my personal usage, what did I need to change to get ride of all of these warnings.

The first warning I saw was "MainPage is now obsolete." or something like that.  Ok, what do I need to do.  Copilot is not hope.  I stuck the message into Google and I got an immediate answer.  I needed to remove setting the MainPage to a value.  Take that out.  Then I had to add in the following method in my App.cs file:

        protected override Window CreateWindow(IActivationState activationState)

        {

            // Set the initial page on the new Window instance

            return new Window(new TabbedNavPage()); // Or any other page

        }

Problem solved.

Monday, December 8, 2025

Adding to the headers in .NET 10

To add to the Response Headers in .NET 10.  I am doing the following.  Specifically, I am setting the Content Security Policy (CSP).  Yeah, I'm doing bad stuff here, get over it.

var headers = context.Request.Headers;

headers.Append("Content-Security-Policy", "frame-src 'self' localhost; style-src 'self' 'unsafe-inline' https://kit.fontawesome.com https://cdn.jsdelivr.net https://code.jquery.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdnjs.cloudflare.com https://cdn.plot.ly https://cdn.jsdelivr.net https://kit.fontawesome.com  https://code.jquery.com");