blazor-server-side

Whole blazor web app stop working when exception occured

╄→尐↘猪︶ㄣ 提交于 2019-12-13 20:16:29
问题 Please advice me any suitable solution for the following issue, when the blazor application throws any exception, the whole application goes down and no link is working, until I can run the application through studio again. what to do with this issue? thanks & best regards Edited (In order to provide requested info) Steps to reproduce: Create a blazorserverside app: Modify IncrementCount At Counter.razor : void IncrementCount() { currentCount += 1; _ = 0 / (5-currentCount); // <-- force error

Blazor.net UI not Rendering anything

寵の児 提交于 2019-12-13 03:54:55
问题 I am developing an Blaor.Net Application , taking reference from many post available on internet . The Problem i am facing that i want to move code from UI to a seprate file to keep razor file clean readable and understandable . For this i am keeping my UI side C# code into a separate component which is inherited from BaseComponent @page "/Item" @using WebApplication1.Shared @using WebApplication1.Client.Services; @inherits ItemComponent @if (ItemList != null) { <table class="table"> <thead>

Blazor Features missing in existing project

僤鯓⒐⒋嵵緔 提交于 2019-12-13 03:39:00
问题 I've started playing around with the new "Blazor Server App" project template in VS 2019 and everything works as expected. Now I've tried to use some Blazor stuff in an existing .NET Core 3 ASP.NET MVC app. I've added ".MapBlazorHub(); & .AddServerSideBlazor();" to the startup class and <script src="_framework/blazor.server.js"></script> to the _layout file. The new razor component gets rendered as expected and the "OnInitialized()" method in the @code block is fired. But when I try to use a

Is there a way to update a binding variable attached to an Input text Item in Blazor when using Ctrl +V combination keys?

扶醉桌前 提交于 2019-12-11 17:05:15
问题 I have this input which is to capture a phone number. When the user enters a number and press the "Enter" Key the Method "KeyWasPressed" is triggered and some validation happens. this works as expected BUT... When the user copies and pastes the number from excel, for example, the variable @Phone doesn't updates its value so when the user presses the "Enter" key the validation sends and empty value. Is there a way to refresh/update @Phone variable when some text is pasted to the input control?

Updating other Blazor components from elsewhere in the application

你。 提交于 2019-12-11 15:52:04
问题 Consider a scenario where you have a dynamic navigation (a list of cheese categories, let's say). The navigation component exists on the layout, which has various other content components. One of those allows the user to update the name of the selected cheese category. But...how do we reflect that back on the navigation component? If one viewed it as a tree you'd have to navigate (in code) up to the layout, then navigate down to the the navigation component where the state can be updated

Share Data Through Service in ASP.NET Blazor (Client Side)

南笙酒味 提交于 2019-12-11 11:01:54
问题 I use to have a common service in MVC Application , register it as Transient service and access its value across whole application without any issue . I tried to implement same mechanism inside my client side blazor app First created a class AppState public class AppState { public string BaseUrl { get; set; } } registered as a service services.AddSingleton<AppState, AppState>(); Used in Blazor Component Index Component public class IndexComponent : ComponentBase { [Inject] HttpClient Http {

Server Side Blazor (Preview 6) - is it possible to require authentication for a particular page?

血红的双手。 提交于 2019-12-11 09:53:43
问题 For a Blazor server hosted page - is it possible to require authentication? Based on the following documentation: https://docs.microsoft.com/en-au/aspnet/core/security/authorization/policies?view=aspnetcore-3.0 I've added the following to my Startup.cs : public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion( CompatibilityVersion.Version_2_2 ); services.AddAuthorization(options => { options.AddPolicy("Private", policy => policy

Blazor sub app 404 error after upgrade to Preview 6

纵饮孤独 提交于 2019-12-11 07:49:16
问题 In Blazor Preview 5 (.Net Core Hosted), I have successfully configured the app as a sub app on the Asp.net Core site using: app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); endpoints.MapRazorPages(); }); app.UseMvcWithDefaultRoute(); app.Map("/superadmin", child => { child.UseBlazor<BlazorCoreHosted.SuperAdmin.Startup>(); }); I am now trying to upgrade to Preview 6, but when the app loads I get a 404 error "Failed to load resource: the server responded

How to get local data source in server side applications?

独自空忆成欢 提交于 2019-12-11 01:39:50
问题 I am using blazor server side application. In that I need to refer local dataSource. I have used the Http as like default client side sample. @code{ ChartData[] dataSource; protected override async Task OnInitAsync() { dataSource = await Http.GetJsonAsync<ChartData[]>("scripts/aapl.json"); } } But I have been facing the issue like below, Can anyone guide me to fix this? 回答1: Unlike client-side Blazor, server-side Blazor requires you to add HttpClient to the DI Container, and inject it into

How do I get client IP and browser info in Blazor?

二次信任 提交于 2019-12-10 16:28:49
问题 How do I get client information such as IP adress and browser name/version in Blazor server-side? 回答1: Note that this is only referring to server-side Blazor . "There is no a good way to do this at the moment. We will look into how we can provide make this information available to the client." Source: Blazor dev at Github Workaround The client makes an ajax call to the server, which then can pick up the local ip number. Javascript: window.GetIP = function () { var token = $('input[name="_