Recent Discussions
C# code causing XSS vulnerability
Hello, We get a vulnerability scan that is show that one of my pages is susceptible to a XSS attack. We are using a telerik tree view to display different data when the nodes are expanded. This is the information they reported back to me. Issue Detail The value of the scrollPosition JSON parameter within the ctl00_ContentPlaceHolder1_VIndex2_tvIndex_ClientState parameter is copied into the HTML document as plain text between tags. The payload sbi7s<script>alert(1)</script>tx52l was submitted in the scrollPosition JSON parameter within the ctl00_ContentPlaceHolder1_VIndex2_tvIndex_ClientState parameter. This input was echoed unmodified in the application's response. Request older1_VIndex2_tvIndex_ClientState=%7b%22expandedNodes%22%3a[]%2c%22collapsedNodes%22%3a[]%2c%22logEntries%22%3a[]%2c%22selectedNodes%22%3a[]%2c%22checkedNodes%22%3a[]%2c%22scrollPosition%22%3a%220**sbi7s%3cscript%3ealert(1)%3c%5c%2fscript%3etx52l**%22%7d&ctl00_RadWindowManager1_ClientState=&__ASYNCPOST=true&ctl00%24ContentPlaceHolder1%24VIndex2%24btnAddCart=Add%20To%20Cart Response > HTTP/2 200 OK > Cache-Control: no-cache > Pragma: no-cache > Content-Type: text/plain; charset=utf-8 > Expires: -1 > Server: Microsoft-IIS/10.0 > X-Powered-By: ASP.NET > X-Frame-Options: SAMEORIGIN > X-Ua-Compatible: IE=edge,IE=11,IE=10,IE=9,IE=8,IE=7 > Strict-Transport-Security: max-age=31536000 > Date: Wed, 19 Mar 2025 16:26:27 GMT > Content-Length: 82 > 68|error|500|0**sbi7s<script>alert(1)</script>tx52l** is not a valid value for Int32.| What is the best way to pinpoint this issue? How do I fix this so it isn't showing up on the scans?Solved62Views0likes3CommentsModule object available in .NET 6 Blazor WASM Project, but not in .NET 8+ After Upgrade
I have a working project in .NET 6 that calls the following JS code: export function synchronizeFileWithIndexedDb(filename) { return new Promise((res, rej) => { const db = window.indexedDB.open('SqliteStorage', 1); db.onupgradeneeded = () => { db.result.createObjectStore('Files', { keypath: 'id' }); }; db.onsuccess = () => { const req = db.result.transaction('Files', 'readonly').objectStore('Files').get('file'); req.onsuccess = () => { Module.FS_createDataFile('/', filename, req.result, true, true, true); res(); }; }; }); } And behind the scenes in OnInitializedAsync: if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("browser"))) { // create SQLite database file in browser var module = await _js.InvokeAsync<IJSObjectReference>("import", "./dbstorage.js"); await module.InvokeVoidAsync("synchronizeFileWithIndexedDb", SqliteDbFilename); } This works perfectly in .NET 6, which is unfortunately now EOL. Simply upgrading it to .NET 8 causes "Module" (see line 11) to no longer be defined. I ran into the same problem using a brand new .NET 9 project as well. If it's .NET 6 it works, .NET 8 or higher it breaks. Is this a known issue? I'm afraid of upgrading anything with JS Interop now 😛 Is there a path forward? I tried changing Module to DotNet, based on reading MSFT docs, but that didn't work. I don't want to go back to .NET 6 to solve this if I don't have to :) You can try it yourself simply by upgrading the following Sqlite WASM project: TrevorDArcyEvans/BlazorSQLiteWasm: Blazor + EF Core + SQLite + WASM All running in a browser together! What could possibly go wrong?Solved62Views0likes1CommentAdding an Icon to the iPhone HomeScreen disables Blazor Server re-connection indefinitely.
When I use my Blazor Server app (.NET 8) with Safari on my iPhone, I am asked to Reconnect to the Server when the connection is lost. I swipe down and a connection is re-established. If I make an Icon on the iPhone Home Screen (mimicking an iPhone app) I am unable to re-establish a Connection. Swiping down to refresh the page does nothing. Is there a solution for this via Blazor Server? Thank youSolved49Views0likes1CommentReact website with ASP.NET and IIS : API not working
Hi, I have found a lot of similar issues on the web but none was working for me, and I am so desperate after days so I am posting here and hope someone can help. I have an ASP.NET server that serves a React website, and also works as an API for the website itself. The server runs on a Windows 11 PC with IIS, in C:/MyWebSite. This folder contains the ASP.NET server (.exe, .dll, etc), the IIS configuration (web.config) and the build React website (index.html, favicon.ico and assets folder). The server succeed to show my main page, but it fails doing an API request. The API request fails as well when I call it from Postman, and gives me the error "HTTP 404.0 - Not Found" with these details : Module IIS Web Core Notification : MapRequestHandler Handler : StaticFile Error code : 0x80070002 FYI, the request is GET http://localhost:5058/api/configuration/settings Concerning ASP.NET, here is my Program.cs : using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; using System.Text; // Create the web application builder var builder = WebApplication.CreateBuilder(args); // JWT authentication builder.Services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(options => { string? tKey = builder.Configuration["Jwt:Key"]; options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = builder.Configuration["Jwt:Issuer"], ValidAudience = builder.Configuration["Jwt:Audience"], IssuerSigningKey = tKey != null ? new SymmetricSecurityKey(Encoding.UTF8.GetBytes(tKey)) : null }; }); // Add the controllers to the application (for input http requests) builder.Services.AddControllers(); // Configure CORS policy builder.Services.AddCors(options => { options.AddPolicy("AllowAllOrigins", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); // Create the App var app = builder.Build(); // Applies the CORS policy app.UseCors("AllowAllOrigins"); // Serving the static files app.UseDefaultFiles(); app.UseStaticFiles(); app.UseRouting(); // Map the routes to the controllers app.MapControllers(); // Undefined route will lead to index.html app.MapFallbackToFile("index.html"); // Run the App app.Run(); Of course, I have created some controllers, here is ConfigurationController.cs for example : using Microsoft.AspNetCore.Mvc; namespace AspReact.Server.Controllers { [ApiController] [Route("api/configuration")] public class GeneralController : ControllerBase { [HttpGet("settings")] public ActionResult GetSettings() { return Ok(new { language = 'fr', theme = 0 }); } [HttpPost("settings")] public ActionResult SetSettings([FromQuery] string language, [FromQuery] string theme) { m_tLanguage = language; m_tTheme = theme; return Ok(); } } } Here is my IIS configuration : <?xml version="1.0"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="React Routes" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" /> </conditions> <action type="Rewrite" url="/" /> </rule> </rules> </rewrite> </system.webServer> </configuration> NB : At first I was not doing : <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" /> And the API request was returning the content of index.html... If it can help. Please note that all this is working during development with the server running in a debug console. I would be grateful for any help! Thanks.Solved256Views0likes2CommentsDynamic form generation from dictionary
ASP.NET Blazor app brand spanking new to the stuff here. Trying a move from Apache PHP. Trying to create a dynamic form from a dictionary generated from a separate class I've banged my head against the wall for hours and can't get past this point. This makes everything a text box.. and When its done this way I can see the data change from the submit method. Any time I try to create a bool (checkbox) or number field I get conversion errors or worse. That dictionary _registry.Fields.FieldsData looks like. (converted to JSON to use here) { "ID": { "ID": "47", "fld_app": "5", "fld_human": "ID", "fld_column": "ID", "fld_enable": "True", "fld_type": "int", "fld_pdotype": "", "fld_length": "NULL", "fld_precision": "", "fld_pass": "", "fld_opt": "False", "fld_opt_table": "", "fld_opt_column": "", "fld_icon_set": "", "fld_regex": "", "fld_uom": "", "fld_placeholder": "", "fld_usr_ID": "False", "fld_link": "", "fld_index": "True", "fld_detail": "True", "fld_form": "True", "fld_order": "1", "fld_title": "False", "fld_required": "False", "fld_double": "False", "fld_encrypt": "False", "fld_time": "False", "fld_image": "False", "fld_unique": "False", "fld_json": "False" }, "Column1": { "ID": "48", "fld_app": "5", "fld_human": "Column1", "fld_column": "Column1", "fld_enable": "True", "fld_type": "nvarchar", "fld_pdotype": "", "fld_length": "50", "fld_precision": "", "fld_pass": "", "fld_opt": "False", "fld_opt_table": "", "fld_opt_column": "", "fld_icon_set": "", "fld_regex": "", "fld_uom": "", "fld_placeholder": "", "fld_usr_ID": "False", "fld_link": "", "fld_index": "True", "fld_detail": "True", "fld_form": "True", "fld_order": "2", "fld_title": "False", "fld_required": "False", "fld_double": "False", "fld_encrypt": "False", "fld_time": "False", "fld_image": "False", "fld_unique": "False", "fld_json": "False" }, "Column2": { "ID": "49", "fld_app": "5", "fld_human": "Column2", "fld_column": "Column2", "fld_enable": "True", "fld_type": "nvarchar", "fld_pdotype": "", "fld_length": "50", "fld_precision": "", "fld_pass": "", "fld_opt": "False", "fld_opt_table": "", "fld_opt_column": "", "fld_icon_set": "", "fld_regex": "", "fld_uom": "", "fld_placeholder": "", "fld_usr_ID": "False", "fld_link": "", "fld_index": "True", "fld_detail": "True", "fld_form": "True", "fld_order": "3", "fld_title": "False", "fld_required": "False", "fld_double": "False", "fld_encrypt": "False", "fld_time": "False", "fld_image": "False", "fld_unique": "False", "fld_json": "False" }, "Column3": { "ID": "50", "fld_app": "5", "fld_human": "Column3", "fld_column": "Column3", "fld_enable": "True", "fld_type": "nvarchar", "fld_pdotype": "", "fld_length": "50", "fld_precision": "", "fld_pass": "", "fld_opt": "False", "fld_opt_table": "", "fld_opt_column": "", "fld_icon_set": "", "fld_regex": "", "fld_uom": "", "fld_placeholder": "", "fld_usr_ID": "False", "fld_link": "", "fld_index": "True", "fld_detail": "True", "fld_form": "True", "fld_order": "4", "fld_title": "False", "fld_required": "False", "fld_double": "False", "fld_encrypt": "False", "fld_time": "False", "fld_image": "False", "fld_unique": "False", "fld_json": "False" }, "Column4": { "ID": "51", "fld_app": "5", "fld_human": "Column4", "fld_column": "Column4", "fld_enable": "True", "fld_type": "nvarchar", "fld_pdotype": "", "fld_length": "50", "fld_precision": "", "fld_pass": "", "fld_opt": "False", "fld_opt_table": "", "fld_opt_column": "", "fld_icon_set": "", "fld_regex": "", "fld_uom": "", "fld_placeholder": "", "fld_usr_ID": "False", "fld_link": "", "fld_index": "True", "fld_detail": "True", "fld_form": "True", "fld_order": "5", "fld_title": "False", "fld_required": "False", "fld_double": "False", "fld_encrypt": "False", "fld_time": "False", "fld_image": "False", "fld_unique": "False", "fld_json": "False" }, "Column5": { "ID": "52", "fld_app": "5", "fld_human": "Column5", "fld_column": "Column5", "fld_enable": "True", "fld_type": "nvarchar", "fld_pdotype": "", "fld_length": "50", "fld_precision": "", "fld_pass": "", "fld_opt": "False", "fld_opt_table": "", "fld_opt_column": "", "fld_icon_set": "", "fld_regex": "", "fld_uom": "", "fld_placeholder": "", "fld_usr_ID": "False", "fld_link": "", "fld_index": "True", "fld_detail": "True", "fld_form": "True", "fld_order": "6", "fld_title": "False", "fld_required": "False", "fld_double": "False", "fld_encrypt": "False", "fld_time": "False", "fld_image": "False", "fld_unique": "False", "fld_json": "False" }, "Column6": { "ID": "53", "fld_app": "5", "fld_human": "Column6", "fld_column": "Column6", "fld_enable": "True", "fld_type": "nvarchar", "fld_pdotype": "", "fld_length": "50", "fld_precision": "", "fld_pass": "", "fld_opt": "False", "fld_opt_table": "", "fld_opt_column": "", "fld_icon_set": "", "fld_regex": "", "fld_uom": "", "fld_placeholder": "", "fld_usr_ID": "False", "fld_link": "", "fld_index": "True", "fld_detail": "True", "fld_form": "True", "fld_order": "7", "fld_title": "False", "fld_required": "False", "fld_double": "False", "fld_encrypt": "False", "fld_time": "False", "fld_image": "False", "fld_unique": "False", "fld_json": "False" } } The .razor component PAGE "/FieldsAdmin" @inject ILogger<FieldsAdmin> Logger @inject portalx.Classes.Main.DBO Database @using System.Data @using System.Collections.Generic @inject portalx.Classes.Main._reg _registry @using System.Text.Json <form method="post" @onsubmit="Submit" @formname="FieldsAdmin"> <AntiforgeryToken /> @if (_registry.Fields.FieldsData != null) { @foreach (var row in _registry.Fields.FieldsData) { <div class="form-row"> @foreach (var field in row.Value) { <div class="form-group col-md-6"> <label>@field.Key</label> @{ var key = $"{row.Key}-{field.Key}"; if (!Model!.DynamicFields.ContainsKey(key)) { Model!.DynamicFields[key] = field.Value?.ToString() ?? string.Empty; } } <InputText @bind-Value="Model!.DynamicFields[key]" /> </div> } </div> } } <div> <button type="submit">Submit</button> </div> </form> <div> <h3>Fields Data (JSON)</h3> <pre>@jsonString</pre> </div> @code { [SupplyParameterFromForm] private ModelFieldsAdmin? Model { get; set; } private Dictionary<string, string> dataDict { get; set; } private string jsonString { get; set; } protected override void OnInitialized() { Model ??= new(); dataDict = new Dictionary<string, string> { { "ID", "hidden" }, { "fld_app", "skip me" }, { "fld_human", "text" }, { "fld_column", "skip me" }, { "fld_enable", "bool" }, { "fld_type", "skip me" }, { "fld_pdotype", "skip me" }, { "fld_length", "skip me" }, { "fld_precision", "skip me" }, { "fld_pass", "bool" }, { "fld_opt", "bool" }, { "fld_opt_table", "text" }, { "fld_opt_column", "text" }, { "fld_icon_set", "text" }, { "fld_regex", "text" }, { "fld_uom", "text" }, { "fld_placeholder", "text" }, { "fld_usr_ID", "bool" }, { "fld_link", "bool" }, { "fld_index", "bool" }, { "fld_detail", "bool" }, { "fld_form", "bool" }, { "fld_order", "number" }, { "fld_title", "bool" }, { "fld_required", "bool" }, { "fld_double", "bool" }, { "fld_encrypt", "bool" }, { "fld_time", "bool" }, { "fld_image", "bool" }, { "fld_unique", "bool" }, { "fld_json", "bool" } }; jsonString = JsonSerializer.Serialize(_registry.Fields.FieldsData, new JsonSerializerOptions { WriteIndented = true }); } private void Submit() { foreach (var kvp in Model!.DynamicFields) { Logger.LogInformation("Field Key: {Key}, Value: {Value}", kvp.Key, kvp.Value); } } public class ModelFieldsAdmin { public string? Id { get; set; } public Dictionary<string, string> DynamicFields { get; set; } = new Dictionary<string, string>(); } }Solved116Views0likes1Commentajax and connection to mvc .net
I need to access some c# code from javascript in MVC ,NET (not blazor). I have the below. This is very specific to .NET and MVC stack and not a generic ajax question like another one in stack overfow. I get no error message it just continues to the next statement after the ajax call. There could be 2 possible issues i think. My url: '/Home/CreatePostcodeFromCoordinates', is wrong. Or my C# assembly is not part of the assembly? or something similar. I am not that experienced with Web techs, I come from a DB background but can't be that difficult to get this link working right? Can't see anything else wrong. Also does the return value from C# need to be some special format or a string (as per now) is ok? this could be another reason? Thank you! console.log("just before /Home/CreatePostcodeFromCoordinates"); $.ajax({ type: "POST", url: '/Home/CreatePostcodeFromCoordinates', data: { param1: longitude, param2: latitude }, success: function (response) { console.log('success'); console.log(response); }, error: function (error) { console.error(error); } });Solved134Views0likes1CommentCheckbox values empty if other form fields are empty when POST form
I have hit a road block on a ASP.NET/Razor Pages project I am working on. I have a form with checkboxes. I have a List<int> field that is bound to the Id of the checkboxes. If I submit the form with only the checkboxes checked the List is always null. However, if I type text in a textbox in the form before submitting, the checkbox values are POST'd correctly. Looking for any hints on things to try or check to to help me narrow down the problem. Thank for any suggestions.Solved280Views0likes2CommentsEF Core : foreign key column with same name as existing navigation property
I want to use EF Core to map a legacy database. I cannot scaffold as there are hundreds of tables and I am only interested in very few and besides scaffolding generates names for the navigation properties which are not the ones I want. The situation is: I have a required many-to-one relationship linked by a column name that matches the name of the property that I want to give. The code (simplified) is: public class EntityProperty { public ControlType ControlType { get; set; } } public class ControlType { public List<EntityProperty> Properties { get; set; } = new List<EntityProperty>(); } Nothing more is required, eg, I'm not using foreign key properties, just navigation. The problem is, the foreign key column from the EntityProperties table to the ControlTypes is also called ControlType. So, when I try to map it as: builder.HasOne(x => x.ControlType) .WithMany(x => x.Properties) .IsRequired() .HasForeignKey("ControlType"); I want to use EF Core to map a legacy database. I cannot scaffold as there are hundreds of tables and I am only interested in very few. The situation is: I have a required many-to-one relationship linked by a column name that matches the name of the property that I want to give. The code (simplified) is: public class EntityProperty { public ControlType ControlType { get; set; } } public class ControlType { public List<EntityProperty> Properties { get; set; } = new List<EntityProperty>(); } The problem is, the foreign key column from the EntityProperties table to the ControlTypes is also called ControlType. So, when I try to map it as: builder.HasOne(x => x.ControlType) .WithMany(x => x.Properties) .IsRequired() .HasForeignKey("ControlType"); I get the following exception: InvalidOperationException: The property or navigation 'ControlType' cannot be added to the 'EntityProperty' type because a property or navigation with the same name already exists on the 'EntityProperty' type.' The problem is with HasForeignKey, I guess it's because I am adding a shadow property when a "physical" property already exists, but I what I really mean to say is to use a different column name to link the two entities: what I want is to be able to specify a "not standard" column name for the foreign key, which I am not able to. I do not have a foreign key property, only a navigation property, and I do not want to have one.Solved2KViews0likes1CommentMSB4011 warnings
Got a project with 2 of these warnings and it seems there's nothing I can do in VS to fix these. Where does it come from and how to solve it ? All I see when showing all files is a Imports folder with subfolders that seems to be links and there's nothing I can do with them in this project. The weird part is that from 12 projects in my solutions only this project exhibit this issue. I wish I could remove these warnings or know how to fix them Severity Code Description Project File Line Suppression State Warning MSB4011 "C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk.Publish\Sdk\Sdk.props" cannot be imported again. It was already imported at "C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk.Worker\targets\Microsoft.NET.Sdk.Worker.props (50,3)". This is most likely a build authoring error. This subsequent import will be ignored. waInvoiceSystem 1 Severity Code Description Project File Line Suppression State Warning MSB4011 "C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk.Publish\Sdk\Sdk.targets" cannot be imported again. It was already imported at "C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk.Worker\targets\Microsoft.NET.Sdk.Worker.targets (24,3)". This is most likely a build authoring error. This subsequent import will be ignored. waInvoiceSystem 1Solved1.2KViews0likes3CommentsException in .Net MAUI App: "System.ObjectDisposedException: Cannot access a closed Stream" on Andro
I am currently developing a .Net MAUI application where I am making an HTTP call. The peculiar issue I am facing is that the function works perfectly fine on Windows, but when I attempt to execute it on my Local Android Device, it throws an exception after line var response = await client.PostAsync(url, content); > "System.ObjectDisposedException: Cannot access a closed Stream." ``` public async static Task InsertParts(IEnumerable<PartDTO> partsToReport) { using (HttpClient client = GetClient()) { AddAuthorizationHeader(client); string url = $"{Url}/endpoint"; string jsonData = JsonSerializer.Serialize(partsToReport); HttpContent content = new StringContent(jsonData, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); if (!(response.IsSuccessStatusCode)) { throw new Exception($"Failed to insert parts: {response.ReasonPhrase}"); } } } ``` ``` public static HttpClient GetClient() { #if DEBUG HttpClientHandler insecureHandler = new HttpClientHandler(); insecureHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; return new HttpClient(insecureHandler); #else return new HttpClient(); #endif } ``` GET and DELETE works on both platforms The Post operation like this works on both platforms > HttpResponseMessage response = await client.PostAsync($"{Url}/inventory/{id}/{destination}", null); but when I try to put content in the request then it does not work on android but works in Windows.Solved2.6KViews0likes2CommentsForm1 Rename Problem in Visual Studio
If you create a Windows Forms project in Visual Studio 2022, it creates a Form1.cs file, a Form1.cs [Design] form, and a Form1.Designer.cs file. You can then drag items from the toolbox onto the form or select the form and using the form properties window to add event handlers like OnPaintForm1, and the Designer will handle those actions appropriately. However, if after creating the project, you immediately rename Form1.cs and its counterparts to, say, MyForm.cs, etc. and then drag items from the toolbox to the form or select the form and use the properties window to add event handlers, the Designer does not appropriately update the renamed form files or form design. What I have to do is use the original Form1 files, add the tools and event handlers, and build the application. After that, I can rename the files and they still work. Is there a way to fix the problem of renaming first?Solved1.4KViews0likes3CommentsInspect the visual tree of a .NET MAUI app IS NOT WORKING!
I am attempting to Inspect a Visual Tree in Windows Maui App and it does not work. Followed the instruction provided on this web page https://learn.microsoft.com/en-us/dotnet/maui/user-interface/live-visual-tree?view=net-maui-7.0&tabs=vswin#find-a-ui-elementInspect the visual tree of a .NET MAUI app I am attempting to see the properties for an element and nothing shows up? It works if I use a WPF Project but not in a MAUI project. Please HelpSolved1.1KViews0likes2CommentsMicrosoft.ACE.OLEDB.12.0 Issue
So I have a C# app that reads from Excel (using Microsoft.ACE.OLEDB.12.0) in order to then add those rows into a larger consolidated sheet. It's worked fine for a long time. Suddenly the past couple of weeks I received trouble reports from endusers that the app isn't functioning. When I debugged it, seems that the Excel source files have zero rows read. No runtime errors or anything. I have verified that the column headings are correct, against the OleDbCommand.CommandText query. And the column headings are based on a generic template that all of these source sheets use. The source sheets have rows of valid data. A year or two ago I recall there was a Windows Update that affected some of these Excel OLEDB operations. Due to MDAC era components being deprecated. Hence why I changed over to ACE OLEDB 12.0. Since I did that this app has run without fail. Anyone know if there was indeed a Windows Update that would've affected things? Running this on Windows 10 Pro. I can provide my source code, although it's been unmodified and is relatively verbose.Solved1.3KViews0likes1CommentDeveloping a .NET MAUI app on a team using Visual Studio on both Windows and Mac
As the title states, our team consists of developers who use Visual Studio 2022 for Mac and for Windows. We are creating a cross-platform application using .NET MAUI, so I'd assume we should be able to contribute using both. However, we seem to have a problem in our .csproj file. In order for the application to load in the solution on Windows machines, the .csproj file must include these lines: <TargetFrameworks>net7.0-windows10.0.19041.0</TargetFrameworks> <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('mac'))">$(TargetFrameworks);net7.0-maccatalyst</TargetFrameworks> However, in order for them to load on Visual Studio for Mac, we must have these lines: <TargetFrameworks>net7.0-maccatalyst</TargetFrameworks> <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks> Is there any configuration we can put that will allow the project to load on either operating system? As the minority OS user, it is quite annoying to have to edit the .csproj each time I switch git branches.Solved569Views0likes1CommentCould not set or bind model property with Bootstrap Datepicker in Blazor
I am using bootstrap datepicker and the problem is that when I pick a date, it does not fire a change or input event and noting is binding with the model property Course.StartDate or Course.EndDate. The default datepicker works but does not support Afghanistan datetime. That is why I use boostrap datepicker. Blazor code: @using Microsoft.AspNetCore.Mvc.Rendering @using myproject.Data @using Microsoft.JSInterop; @inject myproject.Repository.CoursesRepository _coursesRepository @inject IJSRuntime JS <EditForm Model="@Course" OnValidSubmit="e=> { if(selectedId == 0) { addCourse(); } else { updateCourse(Course.CourseId); } }"> <div class="mb-2"> <div>@Course.StartDate</div> <label class="col-form-label" for="StartDate">@Loc["Start Date"]<span class="text-danger fs--1">*</span>:</label> <InputDate class="form-control" @bind-Value="Course.StartDate" @bind-Value:format="yyyy-MM-dd" id="StartDate" /> <ValidationMessage class="text-danger" For="(() => Course.StartDate)"/> </div> <div class="mb-2"> <label class="col-form-label" for="EndDate">@Loc["End Date"]<span class="text-danger fs--1">*</span>:</label> <InputDate class="form-control" @bind-Value="Course.EndDate" @bind-Value:format="yyyy-MM-dd" id="EndDate"/> <ValidationMessage class="text-danger" For="(() => Course.EndDate)"/> </div> </EditForm> @code { public CourseModel Course = new(); public string[] dates = new string[] { "#StartDate", "#EndDate" }; protected override void OnAfterRender(bool firstRender) { base.OnAfterRender(firstRender); loadScripts(); } void addCourse() { _coursesRepository.AddCourse(Course); FillData(); Course = new(); var title = "Course"; Swal.Success(title : Loc[$"{title} added successfully"],toast : true); } // initializes the datepicker public async Task loadScripts() { await JS.InvokeVoidAsync("initializeDatepicker", (object) dates); } } This is script for initializing the datepickers <script> function initializeDatepicker(dates) { dates.forEach((element) => { $(element).datepicker({ onSelect: function(dateText) { // this is not working element.value = this.value; /* tried this and still not working $(element).trigger("change"); also tried this and still not working $(element).change(); */ // this is working console.log("Selected date: " + dateText + "; input's current value: " + this.value); }, dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true }); }); } </script>Solved4.7KViews0likes2CommentsBoolean property true by default !?
I created a class with a Boolean. When I instantiate it, my Boolean is true. I don't understand. I thought the default for Boolean was false ! Any ideas ? Right now, I'm forced to use this attribute : [DefaultValue(false)] public bool IsDelete { get; set; }Solved2.6KViews0likes2CommentsScrapping and Automation
Hey There! Basically, I want to make a website that can scrape data from other websites without using an API in the same way that cURL in PHP scrapes data from other websites. I would like to know if it is possible to do this type of programming in ASP.net . My final year project will be a ASP.net project that focuses on automation and that I wish to do in ASP.net. Thanks.Solved895Views0likes2CommentsMAUI XAML "in-app toolbar" / "xaml inspector" no longer visible
Sorry for using some made up term but I have no idea what this little menu is called. So I referred to it as "xaml Inspector" I have 2 systems opening the same project, one is 17.3 preview 6 and the other is 17.3.2. On the preview version I can see this menu when I debug my MAUI app in Windows. I cannot see it on the 17.3.2 release, which seems to also be part of a wider debugging issue that I'm experiencing. Any idea how to fix this? Maybe I have changed a setting somewhere but am not aware of what. Thanks in advance!Solved1.6KViews1like2CommentsPassing variable to custom controls .NET MAUI
So I'm working on an application that allows the user to create a note and attach it to various entities. Because of this I created the note creation as a ContentView in my .NET MAUI project then I can display it wherever I need it instead of recreating it each time. Is there a way to pass a variable (i.e. contact id from the create contacts page) to the ContentView? 4 days of digging and so far haven't found anything close.Solved3.3KViews0likes2Comments