blazor

How do I detect mobile devices in blazor server side application?

安稳与你 提交于 2021-02-10 18:29:26
问题 I need to detect if the user of my blazor server side application is using a mobile device. Is there any way to find out which device the user is using? I know I can do it with a JSRuntime but is there any way to figure it out with pure C#? 回答1: I did find this article that will read you the width and height of a window in Blazor. Looks like it uses JS Interop. With that, you can determine if a user is using a mobile based on the width of their resolution. Of course, it's not 100% full proof

Blazor: set initial value to a select using onchange and not bind

别来无恙 提交于 2021-02-10 17:35:46
问题 We know that with InputSelect we cannot use both @bind-value and @onchange If we use the latter (with select instead InputSelect) how can we set a initial value different from the first ? (eg. in this sample set to 2018, the value of a variable) Something like if (i == month) => selected <select @onchange="ChangeYear"> @for (int i = 2015; i < DateTime.Now.Year + 1; i++) { <option value="@i">@i</option> } </select> @code { int year = 2018; void ChangeYear(ChangeEventArgs e) { int year =

Random Blazor “Failed to find a valid digest in the 'integrity' attribute for resource” on iis

人走茶凉 提交于 2021-02-10 16:14:41
问题 I am facing an issue when loading a site built and published using blazor. I get the following error message: " Failed to find a valid digest in the 'integrity' attribute for resource 'https://MYWEBSITEURL.com/_framework/System.Private.CoreLib.dll' with computed SHA-256 integrity 'xV9SflNt5Ex5gP7OznQorlp2VkdJXkcAiopU+h5DRzY='. The resource has been blocked. " I assume that the browser blocks the files from downloading because the hashes created when publishing do not match. No files where

How to use Authorization namespace in a shared Razor Class Library Project?

懵懂的女人 提交于 2021-02-10 14:59:46
问题 I can use the Microsoft.AspNetCore.Components.Authorization namespace in my Blazor Server Project. However, I can't get it to work in my Razor Class Library project. I even added the same Nuget Libraries and mirrored the _Imports.razor file, but the library project doesn't recognize this namespace. Is there some limitation or am I doing something wrong? 回答1: The namespace name usually matches an Assembly and a Package. You can easily find out with the F12 key or consult the docs. The page you

How to use Authorization namespace in a shared Razor Class Library Project?

邮差的信 提交于 2021-02-10 14:58:38
问题 I can use the Microsoft.AspNetCore.Components.Authorization namespace in my Blazor Server Project. However, I can't get it to work in my Razor Class Library project. I even added the same Nuget Libraries and mirrored the _Imports.razor file, but the library project doesn't recognize this namespace. Is there some limitation or am I doing something wrong? 回答1: The namespace name usually matches an Assembly and a Package. You can easily find out with the F12 key or consult the docs. The page you

How do I use <ValidationMessage> within a component

[亡魂溺海] 提交于 2021-02-10 14:17:18
问题 Please note that although this is closely related to this question, the answer there is specific to one known model property, whereas I want this to work for any property, so the component is reusable. I want to use the Blazor <ValidationMessage> tag within a component. However, when I do this, the validation message isn't shown. For example, the following component ( FormRowText.razor ) creates a row (in the Bootstrap grid sense) containing an <input type="text /> for a named property on a

Can't reach file in 'wwwroot' when project is deployed

[亡魂溺海] 提交于 2021-02-10 06:31:06
问题 when I work in debug with IIS Express in visual studio and try to reach a file in /wwwroot, I don't have any problem with the path = 'wwwroot/fileName'. But when I deploy my website into IIS Express server, I can't reach the file anymore and I get error because the file doesn't exist. Did I make something wrong ? Did the path is not the same when WebSite is deploy ? PS : The file is '.xlsx' extension 回答1: Most likely the file is not being deployed. Assuming you're using Visual Studio, try

Blazor InputText call async Method when TextChanged

流过昼夜 提交于 2021-02-09 10:34:32
问题 I try to capture text changes of InputText in Blazor (ServerSide) and then call a async method to check if input is correct coupon code or not. HTML: <EditForm Model="@Basket" OnValidSubmit="@CommitBasket"> Gutscheincode <InputText class="coupon-input checkout-control pristine untouched" @bind-Value="CouponCode" @onchange="CouponCodeChanged"> </InputText> @CouponText </EditForm>` But The CouponCodeChanged isn't raised - OnKeyUp is not useful because the Text Value isn't changed at that state.

Blazor InputText call async Method when TextChanged

懵懂的女人 提交于 2021-02-09 10:31:13
问题 I try to capture text changes of InputText in Blazor (ServerSide) and then call a async method to check if input is correct coupon code or not. HTML: <EditForm Model="@Basket" OnValidSubmit="@CommitBasket"> Gutscheincode <InputText class="coupon-input checkout-control pristine untouched" @bind-Value="CouponCode" @onchange="CouponCodeChanged"> </InputText> @CouponText </EditForm>` But The CouponCodeChanged isn't raised - OnKeyUp is not useful because the Text Value isn't changed at that state.

Blazor InputText call async Method when TextChanged

青春壹個敷衍的年華 提交于 2021-02-09 10:31:05
问题 I try to capture text changes of InputText in Blazor (ServerSide) and then call a async method to check if input is correct coupon code or not. HTML: <EditForm Model="@Basket" OnValidSubmit="@CommitBasket"> Gutscheincode <InputText class="coupon-input checkout-control pristine untouched" @bind-Value="CouponCode" @onchange="CouponCodeChanged"> </InputText> @CouponText </EditForm>` But The CouponCodeChanged isn't raised - OnKeyUp is not useful because the Text Value isn't changed at that state.