mvc
55 TopicsBuild Scalable Web Apps and APIs with ASP.NET Core, Blazor, Angular for Modern Web Apps
I’m starting this discussion because many developers today need guidance on how to build modern, scalable web applications and APIs by combining ASP.NET Core, Blazor, and Angular—three powerful technologies within the .NET ecosystem. Whether you're focused on server-side development, creating dynamic client-side apps, or integrating both, these frameworks provide incredible capabilities to enhance your projects ASP.NET Core for API Development: ASP.NET Core is a robust, high-performance framework that allows you to create powerful APIs. Some of the best practices we’ll cover include: - Designing RESTful APIs with ASP.NET Core - Utilizing Entity Framework Core for efficient database access - Securing APIs with JWT and OAuth - Handling asynchronous requests for optimal performance - Implementing API versioning and changes over time Building Dynamic Web Apps with Blazor: Blazor enables you to create interactive web applications using C# instead of JavaScript. We will discuss: - Blazor Web Assembly vs. Blazor Server: Differences and use cases - Creating reusable Blazor components for UI - Integrating third-party JavaScript libraries with Blazor - Using SignalR for real-time features - Optimizing Blazor for performance Angular for Full-Featured Client-Side Development: Angular is a powerful, full-featured front-end framework that excels in creating dynamic and complex user interfaces. In this section, we'll dive into: - Why you might choose Angular over Blazor in certain cases - Using Angular CLI to scaffold, build, and maintain apps - Managing state in Angular with NgRx or RxJS - Connecting Angular with ASP.NET Core APIs for data handling - Working with Angular components, services, and routing for a seamless user experience Combining Angular and Blazor in a Single Application: You may have use cases where you want to combine both Blazor and Angular in one application to leverage the strengths of each framework: - When to use Angular for complex frontend features (e.g., dynamic forms, complex data visualization) and Blazor for simpler components or backend-heavy apps. - Managing communication between Angular and Blazor components in a single page (e.g., using - JavaScript Interop to pass data between the two). - Handling authentication and state management across both frameworks. Integration between Frontend (Blazor/Angular) and Backend (ASP.NET Core): No matter whether you're using Angular or Blazor for the frontend, integrating these with your backend API is key. We'll discuss: - Setting up HttpClient for making API calls from both Blazor and Angular - Working with SignalR to enable real-time features in both frontends - Managing authentication and authorization across both Angular and Blazor (JWT, OAuth) - Best practices for passing data and sharing state between the frontend and backend Scalable and Maintainable Web Apps: When building full-stack web applications, it's important to focus on scalability and maintainability. Here are some practices for achieving this: - Structuring your application code to separate concerns (e.g., services, components, repositories) - Utilizing Dependency Injection for flexible and testable code - Modularizing your codebase for easier updates and maintenance - Using Lazy Loading for Angular and Blazor components to improve performance - Leveraging Caching strategies to enhance response times Testing and Continuous Deployment: For any modern application, testing and deployment are crucial. We’ll discuss: - Unit and integration testing in ASP.NET Core, Blazor, and Angular - Automated end-to-end testing (e.g., with Cypress for Angular, bUnit for Blazor) - Continuous Integration/Continuous Deployment (CI/CD) strategies for seamless deployment to cloud platforms like Azure or AWS When to Choose Angular, Blazor, or Both: It’s essential and interesting to know when to use each of these frameworks depending on your project’s needs. Some scenarios we’ll explore: - When to go for Blazor for a unified C# experience in both frontend and backend - Why you might opt for Angular when building highly interactive, feature-rich web applications - Hybrid approaches where you can use Blazor and Angular together for a robust full-stack solution SO: Combining ASP.NET Core, Blazor, and Angular allows developers to choose the right tool for the right job, creating flexible, scalable, and maintainable web applications. Whether you’re leveraging Blazor for its deep integration with .NET or Angular for its powerful frontend capabilities, these technologies offer a powerful suite of tools to build modern web applications. What are your thoughts? How have you integrated Angular or Blazor with ASP.NET Core in your projects? Share your experiences and challenges, and let's collaborate on solutions!627Views9likes5CommentsManaging web client assets ... and how Snowpack can help
Hello there. I've been wondering what tooling and workflow everyone is using to manage client assets JS/CSS/images etc especially for Blazor and perhaps provide some inspiration in the process (not writing a complete guide, merely a pointer). When trying tools like Libman, Gulp, Webpack, MSBuild it turned out to be either insufficient or too convoluted with lot of complexity and JS code for even basic tasks. My needs were somewhat simple in the head, yet hard to execute: 🟢 Needs to work with CLI/Visual Studio Code ecosystem 🟢 Manage packages with PNPM (faster and more efficient alternative to NPM) 🟢 Self-contained TypeScript source files that would produce fully optimized unbundled importable ESM modules with treeshaking, splitting, minification 🟢 PostCSS with support for nesting, variables, imports. Coupled with TailwindCSS JIT that would automatically generate on-demand minimal CSS styles depending on what is in .razor or even .cshtml & .cs template files. 🟢 All of this would need to happen fast, watcher should rebuild only what is needed every time relevant file is changed and output has to be hot reloaded into running application so work can be done in real-time with current application state. 🟢 Everything must be minimal, automatic, no extraneous declarations and relevant things should sit side-by-side. Only tool that managed to do all this pretty much out of the box is https://www.snowpack.dev/ lightning-fast frontend build tool, designed for the modern web. Configuration is very simple compared to other tools /* snowpack.config.js */ /** @type {import("snowpack").SnowpackUserConfig } */ module.exports = { mount: { assets: "/", //"assets" folder holds source files for our wwwroot pages: "/pages", //tells snowpack to watch for changes in this folder shared: "/shared", //tells snowpack to watch for changes in this folder "../../node_modules/@fontsource/poppins/files": { //Copy some extra files from node_modules to wwwroot/css/files //Snowpack doesn't resolve font imports "yet" url: "/css/files", static: true, }, }, exclude: ["**/*.cs"], //Don't watch or include C# files in the wwwroot, we'd comment this out if they contained classes for TailwindCSS JIT to pick up plugins: [ "@snowpack/plugin-postcss", //Support for PostCSS ideally in `.pcss` files, needs to be installed separately with PNPM [ "@jadex/snowpack-plugin-exclude", //This plugin makes sure these files are watched for changes, but not included in the final wwwroot { paths: ["**/*.razor", "**/*.pcss"], }, ], ], buildOptions: { clean: process.env.NODE_ENV === "production", //Production build should be cleaned up out: "wwwroot", }, optimize: { minify: true, bundle: false, treeshake: true, splitting: true, target: "es2020", }, }; And that's all you need to do with Snowpack, all your assets will build up nicely in the wwwroot, ready to be consumed by the browser. ------------------------------------------------------ Couple notes how things need to be organized CSS Create folder assets/css and put there your css files you want to act as bundles to be placed in wwwroot. In them import individual .pcss files or globs with postcss-import & postcss-import-ext-glob plugins. /* assets/css/app.css */ @import "tailwindcss/base.css"; @import "tailwindcss/components.css"; @import-glob "./**/_components/**/*.pcss"; @import-glob "../../{Pages,Shared}/**/*.pcss"; @import "../../App.razor.pcss"; @import "tailwindcss/utilities.css"; In your index.html or _Layout.cshtml include as normal <link href="css/app.css" rel="stylesheet" /> Snowpack watcher will know when imported pcss is changed and will rebuild the css that imports it. TypeScript Create folder assets/js and put your ts files there /* assets/js/map.ts */ import mapboxgl from "mapbox-gl"; import "mapbox-gl/dist/mapbox-gl.css"; export function initMap(accessToken: string) { mapboxgl.accessToken = accessToken; const map = new mapboxgl.Map({ container: "map", style: "mapbox://styles/mapbox/streets-v11", center: [19.62915, 45.3701] zoom: 15, }); map.addControl(new mapboxgl.FullscreenControl()); map.scrollZoom.disable(); } Don't include in index.html or _Layout.cshtml. Import modules as needed on your pages/layouts. var mapModule = await this.Runtime.InvokeAsync<IJSObjectReference>("import", "./js/map.js"); await this.mapModule.InvokeVoidAsync("initMap", "accessToken"); Other files like Images/Manifests/Favicons Just include in the root of the assets folder or subfolders assets/img etc. It's possible to use plugins to optimize these files too. For example Sharp can be used to optimize, resize images or generate avif/webp variants. Hope someone finds this helpful, should work for MVC and RCL too. Feel free to share your way to tackle the issue or ask questions.1.2KViews2likes0CommentsOpen Source Materio Asp.NET Core MVC Admin Dashboard Template
https://themeselection.com/item/materio-free-aspnet-core-mvc-admin-template/ Hi All, Sharing here https://themeselection.com/item/materio-free-aspnet-core-mvc-admin-template/ If you’re a developer looking for the latest Free ASP.NET Core 8, MVC 5 Admin Panel Template that is developer-friendly, rich with features, and highly customizable look no further than Sneat. Incredibly versatile, this https://themeselection.com/item/category/asp-net-dashboard/ also allows you to build any type of web application. For instance, you can create: SaaS platforms Project management apps E-commerce backends CRM systems Analytics apps Banking apps Education apps Fitness apps & many more. Features: Based on ASP.NET Core 8, MVC 5 UI Framework Bootstrap 5 Vertical layout 1 Unique Dashboard 1 Chart library SASS Powered Authentication Pages Fully Responsive Layout Organized Folder Structure Clean & Commented Code Well Documented You can check the GitHub repo as well: https://github.com/themeselection/sneat-bootstrap-html-aspnet-core-mvc-admin-template-free12KViews1like1CommentOpen Source ASP.NET 8 MVC 5 Admin Template - Sneat
Hi All, Sharing here https://themeselection.com/item/sneat-free-aspnet-core-mvc-admin-template/ If you’re a developer looking for the latest Free ASP.NET Core 8, MVC 5 Admin Panel Template that is developer-friendly, rich with features, and highly customizable look no further than Sneat. Incredibly versatile, this https://themeselection.com/item/category/asp-net-dashboard/ also allows you to build any type of web application. For instance, you can create: SaaS platforms Project management apps E-commerce backends CRM systems Analytics apps Banking apps Education apps Fitness apps & many more. Features: Based on ASP.NET Core 8, MVC 5 UI Framework Bootstrap 5 Vertical layout 1 Unique Dashboard 1 Chart library SASS Powered Authentication Pages Fully Responsive Layout Organized Folder Structure Clean & Commented Code Well Documented You can check the GitHub repo as well: https://github.com/themeselection/sneat-bootstrap-html-aspnet-core-mvc-admin-template-free Hope you all like it.21KViews1like0CommentsASP.Net Core 6 Web App - Fails to connect to database after published to on-prem IIS
Dear Community, I started to learn .Net core and entity framework, and its great. I built a small webapp as a test with a database (SQL LocalDB) and locally on my dev machine, it works fine. I publish to a folder location, then copy locally to a Windows 2019 Server and added a website on the server's IIS. The app will run the razor pages without a model, but the page that serves the model to add data or view data from the SQL database fails and the error is weird and it says there is no server found and cannot authenticate NT Authority\System. I made sure that SQL server express is installed and I can connect, I made sure localDB was added as a feature to the sqlexpress instance, etc., etc., My question is, do I have to do anything funky like wear a foil paper hat, to get this to work? I cant seem to find any documentation at all and youtube tutorials go through all the motions except publishing the app. Any help will be greatly appreciated.6.2KViews1like5Commentstranslate validation message Modal form using ressource file c# not working on server
Hi, I am working on asp.net mvc c# project. On the login page, I have a login form and also a link to the "Forgot password" page and also a page to register. at the top of the page, we have the choice of language, either French or English and the validation of these forms is done via the Modal using 2 resource files with the 2 languages. Everything I have put in place works well locally but by deploying the project, the part of the translation of error messages from non-functional resource files .. is there any config to do please? Thank you.1.3KViews1like2Comments