question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET 6 compability seems to be broken or I'm doing something wrong

See original GitHub issue

Hello,

So I followed the tutorial on how to implement a modal/banner,

My Startup.cs:

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Majorsoft.Blazor.Components.GdprConsent;

namespace _34digital.ruhr
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Register dependencies
            services.AddGdprConsent();
            services.AddRazorPages();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });
        }
    }
}

No errors appeared here. But as soon as I add the code for the banner/modal into _Layout.cshtml or any new shared razor page I get a lot of errors. The most common error type is Name X is not available in current context. Here’s a screenshot of the errors marked.

grafik

I am using .NET Core 6 (Blazor) on Visual Studio 2022 Preview 3.1

P.S. yes I’m a beginner at .NET Core and C# in general

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
munchkindevcommented, Aug 27, 2021

Thank you so much for answering this so in-depth and even though it was completely not related to your component, I really really appreciate it!

0reactions
majorimicommented, Aug 27, 2021

Partially true… When you create a Blazor WASM application (client side) then yes it is true. But Blazor is super flexible it has many hosting models. You can have server side/server hosted Balzor with different render options. Check out render-mode options there is even a “hybrid” where your app renders some HTML to show in the browser (this HTML can have meta tags) and then app will switch to WASM mode.

So Blazor is not a SPA framework as you might think. It is a component based “Web” application framework. And even “WEB” is in quotes since Blazor will be everywhere pretty soon… If not there already… If you write your Blazor components correctly (e.g. no DB or private resource access in the components which will fail on WASM mode) then you can use the SAME components in all apps below:

  • Browser client side SPA with WASM
  • Server side hosting or even rendered or Hybrid render than switch to WASM
  • Existing MVC applications also can host some Blazor components
  • Blazor Electron for Chromium based desktop applications
  • WebWiew components added to MS desktop apps like WinFroms and WPF so Blazor components can be shown in existing even super old windows desktop apps.
  • Blazor Flutter for native Mobile apps, since Blazor also very modular so MS now can switch the component tree renderer from HTML to Flutter mobile UI renderer…

Even at any point in time you just “port” your application from Server side to WASM or Electron on Mobile with “minimal” effort… Hope this answered your questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET 6 Core Web App Returns web page not found
I've created a mirror project in NET5 in VS2019 with the same port, and it works fine. Trying NET6 from VS 2022 does...
Read more >
Breaking changes in .NET 6
This article indicates whether each breaking change is binary compatible or source compatible: Binary compatible - Existing binaries will load ...
Read more >
Azure DevOps Pipeline doesn't support .NET 6? (VS2019 ...
NET 6 and wanted to execute a "build, test and publish" pipeline on Azure DevOps. That fails because the hosted agent does not...
Read more >
Migrating to .NET 6 : r/dotnet
I'm a person who edits project files by hand and I tend to use imported props files and if you do that it's...
Read more >
Cannot debug net6.0-macos Apps - Developer Community
A fix for this issue has been internally implemented and is being prepared for release. We'll update you once it becomes available for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found