Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I work on blazor .net core web app . I need to know what blazor type i work on it
web assembly or server side .

and what is different practically .
i need different on practical points

What I have tried:

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.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddHttpClient();
            services.AddRazorPages();
            services.AddServerSideBlazor();
          
            services.AddTransient<ILocalStorageService, LocalStorageService>();
            services.AddSweetAlert2(options => {
                options.Theme = SweetAlertTheme.Dark;
            });
            services.AddScoped<IserverNamesService, ServerNameService>();
            services.AddScoped<IDatabaseService, DatabaseService>();
            services.AddScoped<IapplicationService, ApplicationService>();
            services.AddHttpClient();
            //services.AddScoped<HttpClient>();
            services.AddAutoMapper(typeof(Startup));

            //Configration
            services.Configure<Schema>(Configuration.GetSection("Schema"));
            services.Configure<DBConnectionAppIds>(Configuration.GetSection("DBConnectionAppIds"));

            var connection = "Server=EGRNDDEVL15\\AHMEDSALAH;database=UC_AppRepository_PY;uid=sa;Password=ahmed@123;Encrypt=false;";
            connection = connection + "TrustServerCertificate=True;";

            //DB Context 
            //var connection = new DBCredentials().GetConnectionString(Configuration["DBConnectionAppIds:AppID"]);
            //connection = connection + "TrustServerCertificate=True;";
            services.AddDbContext<AppsRepositoryDBContext>(options => options.UseSqlServer(connection));


            services.AddTransient<IConnectionDatabase, ConnectionDatabase>();

            //Services 
            services.AddScoped<ILoginService, LoginService>();
            services.AddTransient(typeof(IRepository<>), typeof(BaseRepository<>));
            services.AddScoped<ICommonService, CommonService>();
         
            services.AddScoped<IEmplyeeService, EmplyeeService>();
            services.AddControllers();

            services.AddScoped<IRegisterService, RegisterService>();
            services.AddScoped<ILocalStorageService, LocalStorageService>();


            //Identity Authentication
            services.AddIdentity<IdentityUser, IdentityRole>(Option => Option.SignIn.RequireConfirmedAccount = false)
                  .AddDefaultUI()
                  .AddDefaultTokenProviders()
                  .AddEntityFrameworkStores<AppsRepositoryDBContext>();

         

        }

        
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

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

            app.UseRouting();


            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");
            });
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
    }
}
Posted
Updated 4-Mar-23 10:40am

That's what the documentation is for: ASP.NET Core Blazor hosting models | Microsoft Learn[^]
 
Share this answer
 
ServerSide:
C#
services.AddServerSideBlazor();

WebAssembly:
C#
var builder = WebAssemblyHostBuilder.CreateDefault(args);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900