Recent Discussions
ajax 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); } });Solved97Views0likes1CommentCheckbox 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.Solved212Views0likes2CommentsEF Core : foreign key column with same name as existing navigation property
Iwant 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 theEntityPropertiestable to theControlTypesis also calledControlType. 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 theEntityPropertiestable to theControlTypesis also calledControlType. 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.Solved1.5KViews0likes1CommentMSB4011 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 1Solved1KViews0likes3CommentsException 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.5KViews0likes2CommentsForm1 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.3KViews0likes3CommentsInspect 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 theOleDbCommand.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.2KViews0likes1CommentDeveloping 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.Solved559Views0likes1CommentCould 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 propertyCourse.StartDateorCourse.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.6KViews0likes2CommentsBoolean 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.4KViews0likes2CommentsScrapping 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.Solved847Views0likes2CommentsMAUI 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.5KViews1like2CommentsPassing 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.2KViews0likes2CommentsIssue with unexpected capability Microsoft.storeFilter.core.notSupported_8wekyb3d8bbwe
Dear comunity, we are preparing an update of our app on the Microsoft partner Center portal. After uploading the new “.appxupload” package, in addition to the capabilities we defined in the app manifest, we also find the following capability: "Microsoft.storeFilter.core.notSupported_8wekyb3d8bbwe" We tried to execute again the app build, also verifying the app manifest, but we still obtain such extra capability that seems to be added after the upload of “.appxupload” package. We also tried to search in the Web for it, but we didn’t get any clarification. Can you please provide us clarifications about such extra capability? Can be an issue during review phase for the app we have to release? Thank you in advance, Kind regards,Solved1.1KViews0likes2CommentsBuild error MT0057 for .net Maui iOS, Mac Catalyst builds with no problem
I can build and run for Mac Catalyst fine with this command dotnet build -t:Run -f net6.0-maccatalyst MyApp.csproj but when I try to build for iOS using this command dotnet build -t:Run -f net6.0-ios -p:_DeviceName=:v2:udid=********-************** MyApp.csproj I get this error EXEC : error MT0057: Cannot determine the path to Xcode.app from the sdk root '/Library/Developer/CommandLineTools'. Please specify the full path to the Xcode.app bundle. [/Users/chris/Documents/Development/MyApp/src/MyApp/MyApp.csproj] /usr/local/share/dotnet/sdk/6.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(897,5): error MSB3073: The command "/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.2.302-preview.14.122/tools/bin/mlaunch --launchsim bin/Debug/net6.0-ios/iossimulator-x64/MyApp.app/ --device :v2:udid=********-************ --stdout /dev/ttys000 --stderr /dev/ttys000 --wait-for-exit" exited with code 1. [/Users/chris/Documents/Development/MyApp/src/MyApp/MyApp.csproj] It is odd that it can find XCode for Catalyst but cannot find it for iOS. Any help would be appreciated.Solved2KViews0likes2CommentsBest practice to fill one column with manipulated values from another (DataFrame)?
C# 10 / .NET 6 / Microsoft.Data.Analysis Given aMicrosoft.Data.AnalysisDataFramewith two columns, what is the idiomatic way to take values from one column, manipulate them, then use the resulting value to fill the rows of the second column element-wise? // Create a DateTime column. PrimitiveDataFrameColumn<DateTime> dateTimeCol = new("Dates", 0); // Fill it. dateTimeCol.Append(DateTime.Now + TimeSpan.FromDays(1)); dateTimeCol.Append(DateTime.Now + TimeSpan.FromDays(2)); dateTimeCol.Append(DateTime.Now + TimeSpan.FromDays(3)); // Create a Ticks column. PrimitiveDataFrameColumn<long> ticksCol = new("Ticks", dateTimeCol.Length); // Create a DataFrame of the above two columns. DataFrame df = new(); df.Columns.Add(dateTimeCol); df.Columns.Add(ticksCol); At this point, what I want to do isdf["Ticks"] = df["Dates"].Ticks. Of course, this doesn't work. I could do this: for (int i = 0; i < df.Rows.Count; i++) { DateTime tempDate = (DateTime) df[i, df.Columns.IndexOf("Dates")]; df[i, df.Columns.IndexOf("Ticks")] = tempDate.Ticks; } But... is there a better way?Solved2.5KViews0likes4CommentsSpecific website to recruit .NET talent
Hi, this might have been raised before, I apologize beforehand if that's the case: Where is a website to recruit specifically engineers/developers with expertise in .NET? A while ago I was searching for Blazor developers and using regular recruiting sites it was impossible to find any. Today I'm looking to recruit a .NET / C++ interop expert and, same as above, in regular recruiting sites they don't abound. I think the problem is that those websites typically have a huge pool of the current most popular languages and less so of .NET. So, is there a specific website typically used to recruit .NET talent? If not, wouldn't it be really important to build such? And, if so, in the meantime, what's the best way to find and recruit .NET developers? Thank you! FedericoSolved593Views0likes1Comment