Recent Discussions
A strange run issue
I encountered a strange operational issue. After packaging my software in. msixbundle format, I installed and tested it locally. When clicking on the program icon in the start menu, an error occurred and a DLL could not be found. However, after confirmation, the main interface of the program can be opened. In fact, this DLL and the program's exe are in the same directory. But in the program files \ windows app \ myapp directory, clicking on this exe will allow the program to execute normally. My program is a. NET 8 winform program. How should I do?5Views0likes0CommentsHow to run a .NET Desktop Runtime app
So, Microsoft, this is an incredible piece of trolling and we all appreciate the laugh...but seriously, how do we run our program? Your "Download it now" button does nothing. Your "Download link" does nothing and is useless as text. As you can see in the screenshot, I have multiple versions installed and it still won't run. We tried this on multiple computers (a mix of Win 10 and Win 11) with the same results.18Views0likes0CommentsExtract images from excel stored as Place in cell
Hello experts, I am trying to extract images from an Excel file using a C# program. My code successfully retrieves images that are placed over cells in the worksheet. Now, I need to adapt this functionality so that it can retrieve images which are stored as Place in cell in the excel .I want use this Azure Function for Business Central integration here is the code using Openize.Cells; using System.IO; using DocumentFormat.OpenXml; class Program { static void Main(string[] args) { string filePath = "C:\\Users\\Raj.Kamal\\Downloads\\test.xlsx"; // The path to your workbook string outputDirectory = "C:\\Users\\Raj.Kamal\\Downloads"; // Load the workbook from the specified file path Workbook wb = new Workbook(filePath); // Select the first worksheet from the workbook var worksheet = wb.Worksheets[0]; // Extract images from the worksheet var images = worksheet.ExtractImages(); // Check if the output directory exists; if not, create it if (!Directory.Exists(outputDirectory)) { Directory.CreateDirectory(outputDirectory); } // Loop through each extracted image foreach (var image in images) { // Construct a unique file path for the image using a GUID var outputFilePath = Path.Combine(outputDirectory, $"Image_{Guid.NewGuid()}.{image.Extension}"); // Save the image data to the constructed file path using (var fileStream = File.Create(outputFilePath)) { image.Data.CopyTo(fileStream); } } } } Any code snippets, documentation links, or best practices would be greatly appreciated. Excel file:21Views0likes0CommentsMulti-project launch profiles not working
Hi, I am using Visual Studio 2022 (version 17.12.3) for an ASP.NET + React project. I want to take advantage of the new launch profiles feature to have multiples profiles for http and https, edge and chrome, etc. The feature is enabled, and I am able to create my profiles. So far so good. I have even ticked the share box so a .slnLaunch has been created. But when I am back to the main VS screen, I don't have the dropdown list in my toolbar to chose the profile to launch. I just have the old tooldbar : I tried to : Restart VS Restart my PC Disable/enable the feature with VS restarts in between Sorry for the screenshots in french btw ;) Thanks in advance !74Views0likes0CommentsReact 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.Solved86Views0likes2CommentsMaui.NET and XCode validation
My application is developed on a Windows PC using Visual Studio 2022 (ver. 17.12.1) and .NET MAUI framework (ver. 9). After a successful build and testing using a virtual iPhone interface, Visual Studio connects remotely to the MacBook (Mac OS 15.1) sending the necessary project files to Xcode 16.1 targeting iOS version 18. The files are sent to Xcode successfully. However, Xcode validation fails with 4 errors. No matter what I change, the same errors persist. These validation errors are preventing me from deploying the code to TestFlight. Apple support refuses to help stating it is a problem with Visual Studio compilation of the package for Xcode. While I am not 100% confident, I suspect that the entries in the plist.info file contained within the project do not agree with where the files are physically located (even though they appear correct. However, I cannot see the key values in the plist file in the Xcode IPA package. I also notice that Maui opted to create entries in the plist.info file for “Assets.xcassets/AppIcon.appiconset”, but according to apple this is not how it should be done anymore. Could anyone provide thespecific changes in detail that need to happen to this project to have a successful XCode validation? I have been at this for two weeks with no solution in site. Below is a link to the referenced resources. Screenshots and Error documents Your help is greatly appreciated35Views0likes0CommentsMultiple ASP.NET Core Web API instances runs only once
I have an ASP.NET Core 8.0 Web API hosted on two IIS applications (app-1 and app-2) under the Default Web Site on a Windows 11 OS. Both IIS applications point to the same physical path (inetpub\wwwroot\myapp) and each application has its own dedicated application pool (app1andapp2). The application pools have unique identities (app1svcandapp2svc), both of which are members of the Administrators group. In the Web API, I have anAppEventsclass implementingIHostedService, withStartAsyncandStopAsyncmethods to handle application start and stop events. In theProgram.cs, I register it usingbuilder.Services.AddHostedService<AppEvents>(). When accessinghttp://localhost/app-1, theStartAsyncmethod is triggered as expected. However, when accessinghttp://localhost/app-2, theStartAsyncmethod does not execute. It seems that the application starts only once, despite both IIS apps pointing to the same physical directory. I've tried changing theAspNetHostingModelfromInProcesstoOutOfProcess, but the behavior remains the same. Is there a way to deploy multiple instances of the same web app, each running separately but pointing to the same physical directory, so that each instance correctly triggers its own StartAsync?26Views0likes0CommentsEnhancing Console.ReadLine to Accept a Message Parameter
n Python, the input function allows you to display a message and wait for user input in a single line of code. However, in C#, achieving the same functionality requires two lines: one for Console.WriteLine to display the message and another for Console.ReadLine to capture the input. Is it possible to have a ReadLine function in C# that takes a message as a parameter and waits for user input?8Views0likes0CommentsAutomation testing for ToastNotifications
I am testing a WPF application, and I want to access a button on a Toast Notification. I am using the Microsoft UI Automation framework, but cannot locate the Notification window in the RawView tree or from the RootElement (.Find*). However tools like Inspect do find the Notification window. => what is the issue here? I could use NotificationListener, but that doesn't give access to any button. Correct me if I'm wrong. So how can I access those Toast Notifications with MS UI Automation?32Views0likes0CommentsDotnet core Oracle 23c SSL connection not working on Linux environment and works on Windows
Our data direct ADO.NET oracle driver is having an issue with SSL connection on Linux platform and the same connection is working on windows environment with Oracle23c server. Are there any known limitations with dotnet core on linux environment with SSL/TLS connections. Trace : InnerException: System.IO.IOException Message: Unable to read data from the transport connection: Connection reset by peer. Source: System.Net.Sockets Stack Trace at System.Net.Sockets.NetworkStream.Read(Span`1 buffer) at System.Net.Security.SslStream.EnsureFullTlsFrameAsync[TIOAdapter](TIOAdapter adapter) at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](TIOAdapter adapter, Memory`1 buffer) at System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 count) The same application works on Windows environment.205Views0likes1Commentunable to load the css and javascripts when we use Content-Security-Policy in custom headers
https://itcui2022.revalweb.com/this is my site here am using content security policy below code i have added in my web application web .config . This is the custom header code in web.config <customHeaders> <remove name="X-Powered-By" /> <remove name="Vary" /> <remove name="X-XSS-Protection" /> <add name="Vary" value="Accept-Encoding" /> <remove name="server" /> <add name="Content-Security-Policy" value="default-src 'none';script-src 'self' ;object-src 'self' 'https://www.youtube.com/embed/OBI84brdBCI';style-src 'self' ;base-uri 'self';form-action 'self';img-src https: http: ;font-src https: ; frame-ancestors 'self';"/> <add name="X-Xss-Protection" value="1; mode=block" /> <add name="Referrer-Policy" value="strict-origin" /> <add name="X-Content-Type-Options" value="nosniff" /> <add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains" /> <!-- <add name="X-Frame-Options" value="SAMEORIGIN" /> <add name="Permissions-Policy" value="fullscreen=()" />--> </customHeaders> So am getting below issues in console entire site design also disturbed please help me to resolve this. localhost/:1 Failed to find a valid digest in the 'integrity' attribute for resource 'http://localhost:56244/css/bootstrap.min.css' with computed SHA-384 integrity 'YXdFsF5q5GYktpRMSNNglqzoOPh17LejMdqUx5CXo84zUtjPaKjj5E1CTAINo/gk'. The resource has been blocked. localhost/:1 Failed to find a valid digest in the 'integrity' attribute for resource 'http://localhost:56244/javascripts/bootstrap.min.js' with computed SHA-384 integrity 'LG+vq3DwW7iX7BcYlMMlJ2l3yRf5XT8RtkvDeGZJHSNNiF7KSTtg0yQKiLqNFm4V'. The resource has been blocked. localhost/:23 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-CvgPuDff3Hho4hKb1ZC6y9r6+XXqbP9sOgZajf3I+F4='), or a nonce ('nonce-...') is required to enable inline execution. localhost/:78 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-UITiqbXyaWS7NpwiFrMIbdXAZy5EXLRUHkpylF4504k='), or a nonce ('nonce-...') is required to enable inline execution. localhost/:1 Refused to load the script 'http://ajax.aspnetcdn.com/ajax/4.6/1/WebForms.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback. localhost/:96 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-CeYEunz5VQqxyULB+XWOP3sCX+mM+bzfzViw7EPtnwk='), or a nonce ('nonce-...') is required to enable inline execution. localhost/:1 Refused to load the script 'http://ajax.aspnetcdn.com/ajax/4.6/1/MicrosoftAjax.debug.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback. localhost/:104 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-UxpZhPiRPznGyJM1BSK89gIr0wkT40MeN0ykcKyVQzc='), or a nonce ('nonce-...') is required to enable inline execution. localhost/:109 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-2vr5KMButMK7a+bOf/ned/cPnF2yNooMulXA8E65wGw='), or a nonce ('nonce-...') is required to enable inline execution. localhost/:1 Refused to load the script 'http://ajax.aspnetcdn.com/ajax/4.6/1/MicrosoftAjaxWebForms.debug.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback. localhost/:116 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-EpuJI/NmOAh04fBw4hE5sQRnVYZ4A9EfEP8nroT/9cM='), or a nonce ('nonce-...') is required to enable inline execution. localhost/:126 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-1Dj1GXl5SCvtMhdy8uv1Akr4WD7Y0kPmIK5ElIF9/mc='), or a nonce ('nonce-...') is required to enable inline execution. 24Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-0EZqoz+oBhx7gF4nvY2bSqoGyy4zLjNF+SDQXGp/ZrY='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. localhost/:174 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-biLFinpqYMtWHmXfkA1BPeCY0/fNt46SAZ+BBk5YUog='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. 42Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-ZdHxw9eWtnxUb3mk6tBS+gIiVUPE3pGM470keHPDFlE='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. 14Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-hAo6fw2WF0zjZtf7VZZQ6YI8Z3kPHD8B8b8Gtcx2oOI='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. 18The source list for the Content Security Policy directive 'object-src' contains an invalid source: ''<URL>''. It will be ignored. 18Refused to frame '<URL>' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'frame-src' was not explicitly set, so 'default-src' is used as a fallback. localhost/:513 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-N6tSydZ64AHCaOWfwKbUhxXx2fRFDxHOaL3e3CO7GPI='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. localhost/:941 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-aqNNdDLnnrDOnTNdkJpYlAxKVJtLt9CtFLklmInuUAE='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. localhost/:977 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-7BnD9RIDXeUB9VD92tBlPwhEL1M/jh47BswRP35nxws='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. localhost/:998 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-+4oP7rS92I5ztYUBTys+bZMuh7XsZzbA8I7p/nx5hc4='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. localhost/:1020 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-vqdnKTbt/TvY3ePneXpp1hIoJNbqOs8DRqOx+stBf54='), or a nonce ('nonce-...') is required to enable inline execution. localhost/:1673 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-5TmCSWsRHHKtNC4AgS23KS5Z9SBqma0xikI6H6iJ1/Y='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. localhost/:1705 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-a41VY2GgLCaYKz1KViZdYGquxnzPLRrCGAZskHvjZCQ='), or a nonce ('nonce-...') is required to enable inline execution. localhost/:1710 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-p5EEK9dIuQvZLAPvcG9WSh/ajegn6KGDbAs3bZJTmdE='), or a nonce ('nonce-...') is required to enable inline execution. localhost/:1 Refused to load the script 'https://www.googletagmanager.com/gtag/js?id=G-PSJZ21FT8N' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback. localhost/:1793 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-aFDORWdyFevVNsFN1yqS+nyf7tQzWbrtxHF06snqgPQ='), or a nonce ('nonce-...') is required to enable inline execution. localhost/:1 Refused to load plugin data from 'https://www.youtube.com/embed/OBI84brdBCI' because it violates the following Content Security Policy directive: "object-src 'self' 'https://www.youtube.com/embed/OBI84brdBCI'".214Views0likes1Comment- 45Views0likes2Comments
Is it possible to run a asp.net core site within testing?
Hi! I'm trying to write tests for a small minimal API based on asp.net core. I don't want to test over the internet, but start the app within the tests and call the endpoints on the running site. Is this possible? And how? Should I use TestServer for this? I'm new to writing tests, so maybe it's an easy issue to code. Thanks! :)12Views0likes0CommentsHow can I find CPE of dll in .NET?
For example, System.IO.Packaging 8.0.0 hav weakness. https://www.nuget.org/packages/System.IO.Packaging/8.0.0 I have Vulnerability Management tool, I can receive notice of the weakness by registering CPE. I want to obtain CPE of System.IO.Packaging, but where is it available from? Thanks11Views0likes0CommentsPregunta PdfViewer
Hola a todos Estoy trabajando con PdfViewer de Patagames para visualizar PDFs en un formulario WindowsForm. Tengo dos botones, uno para ajustar al ancho de página y otro para mostrar toda la página, pero no consigo implementar el código. ¿Podrían ayudarme? Gracias de antemano.16Views0likes0CommentsHow to increase session timeout
Hello Everyone, I am working on .NET framework 4.8 with a MVC web application. To login I am using MFA with microsoft's openid-configuration method. When I create FormsAuthenticationTicket and try to set session timeout as per my requirement but it doesn't work. See the sample code as below FormsAuthenticationTicket ticket1 = new FormsAuthenticationTicket( 1, // version adminEmail, // get username from the form DateTime.Now, // issue time is now DateTime.Now.AddDays(365), true, // cookie is not persistent "XXXXX" // role assignment is stored in userData ); But it is not working properly, it gets timeout within 15 mins41Views0likes0CommentsQuestion about Kubernetes Deployment tutorial on Microsoft Learn
I am going through the tutorial Module on Microsoft Learn titled "Deploy a .NET Microservice to Kubernetes" and am on the third unit located here: https://learn.microsoft.com/en-us/training/modules/dotnet-deploy-microservices-kubernetes/3-exercise-push-to-docker-hub. I am stuck under the "Verify the Docker images by creating containers in the codespace" heading on the fourth step. It tells you to select the port for the front end and open the service in a browser. However, there were no ports here that the step seemed to suggest were already there and I had to set it up. Given that the port for the frontend service of this tutorial is 32000:8080 according to the docker-compose.yml file for this tutorial project, is this what I should put in the ports tab? If so, the service does not display in my browser when I click on the globe icon as instructed by the tutorial and all I see is an HTTP 502 message. What should I do so that I can view the service? The repository for this tutorial service is located at https://github.com/MicrosoftDocs/mslearn-dotnet-cloudnative in the dotnet-kubernetes folder and I have attached images as well of the discussed configuration and error message below:34Views0likes0CommentsDynamic 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>(); } }Solved63Views0likes1Comment