Home - potatoscript/asp.net.core.mvc GitHub Wiki

ASP.NET Core MVC

Title Remark
Basic Introduction An introduction to the core concepts of ASP.NET Core MVC. Learn the basic structure of MVC and how it helps in building web applications.
Calling Methods from View Learn how to call C# methods directly from your view. Understand the connection between controllers and views.
Creating Charts Explore how to integrate charts in your web applications to represent data visually.
Creating New Data Learn how to insert data into a database and display it on a web page using ASP.NET Core MVC.
DbContext Setup Learn how to connect and interact with a SQL Database using DbContext in ASP.NET Core.
Deploying and Error Handling A step-by-step guide on deploying your ASP.NET Core MVC application to IIS, including error handling strategies.
Drop Down List in MVC Learn how to create dynamic drop-down lists to display data from the database.
Font Awesome Integration Use Font Awesome icons to enhance the visual experience of your web application.
Get Current User Identity Learn how to retrieve the identity of the currently logged-in user.
Access Data from appsettings.json Learn how to fetch configuration settings from appsettings.json in your MVC application.
Pass Data to JavaScript Use AJAX to pass data from your MVC controller to the front-end JavaScript for dynamic behavior.
List Data from Database Learn how to fetch and display a list of items from a database using ASP.NET Core MVC.
Login and Registration Learn how to implement a login and registration system with PostgreSQL for managing user authentication.
Connecting to NpgSql Database A guide to connecting your ASP.NET Core MVC application to a PostgreSQL database using NpgSql.
Pagination (Page Size & Number) Implement pagination in your MVC application to efficiently display large sets of data.
Advanced Pagination Learn how to implement a more complex pagination system with the ability to navigate between different groups of data.
Passing Data to Views Learn how to pass data from a controller to a view in ASP.NET Core MVC.
POST Data from JavaScript to Controller Learn how to send data from JavaScript to your MVC controller using AJAX POST requests.
Popup Input Window Implement pop-up windows in your application to capture user input without leaving the current page.
Redirecting Between Views Learn how to redirect users to different views using the RedirectToAction method.
Reloading Index with Parameters Learn how to reload your Index view with parameters to update the displayed content dynamically.
Returning Data to Views Learn how to return to another view after an HTTP POST or GET request.
SelectItemList with Default Value Learn how to set default values in select item lists, making your forms more user-friendly.
Search Content Implement search functionality to filter content based on user input.
File Upload & Download Learn how to implement file upload and download features in your ASP.NET Core MVC application.
Input Validation Learn how to validate user input in forms to ensure data integrity.
Web.config File Setup Configure your Web.config file to manage settings such as maxQueryString size for better performance.
Read Values from Local Settings Learn how to read environment-specific settings from local.settings.json for secure application configurations.
Handling JSON Data Learn how to work with JSON data in your ASP.NET Core MVC applications.
MemoryStream in ASP.NET Core Understand how to use MemoryStream for efficient data handling in your application.
Dependency Injection Learn how to implement Dependency Injection in ASP.NET Core MVC to improve code maintainability.
Using Dictionary for JSON Data Learn how to use Dictionaries to manage JSON data, especially in Vue.js front-end applications.
Exception Handling Best practices for handling exceptions in ASP.NET Core MVC to ensure a smooth user experience.
Authentication & Authorization Learn the difference between authentication and authorization, and how to implement them in your application.
Real-time Data with SignalR Implement real-time communication between the server and client using SignalR in your ASP.NET Core MVC application.

ASP.NET Core MVC Cheat Sheets

Title Remark
Basic Introduction to Core MVC concept
Calling Method from View
Chart
Create new Data Insert data into Database and display it in the View
DbContext Connect to SqlDatabase
Deploy or Publish and Error Handler Deploy and Host ASP.NET CORE Application on IIS
Drop Down List
Font Awesome https://fontawesome.com/
Get current user Identity
Get data from appsettings.json
GET data to Javascript $.AJAX GET
List Data Create a List to display data from database
Login & Register Identity Login and Registration Form with PostgreSQL
NpgSql Database Connect to NpgSQL Database
Pagination (pageSize * pageNumber)-pageSize
Pagination2 page number and next group
Passing data to View Select table get Id and display the relevant data to the View
POST data from Javascript to Controller $.AJAX POST
Popup Input Window Show the other View in popup window
RedirectToAction go to other view
Reload Index with parameter Reload Index from Javascript
Return Return to other view after http post or get
SelectItemList how to set default value
Search Content how to filter list content by search key
Upload & Download File
Validation Check the input text value
Web.config file Create Web config to set maxQueryString
Read values from local.settings.json Environment.GetEnvironmentVariable("AzureWebJobsStorage")
Json data handling Check double data example
MemoryStream encapsulates data stored as an unsigned byte array, which can reduce the need for temporary buffers and files in an application. The current position of a stream s the position at which the next read or write operation takes place
Dependency Injection https://youtu.be/YR6HkvNBpX4
Dictionary Create dictionary json data for vue.js front end
  1. Cannot use a lambda expression as an argument to a dynamically dispatched operation
    without first casting it to a delegate or expression tree type.
    • solution:
@model dynamic
@using System.Collections.Generic
@{
  var XLabels = Newtonsoft.Json.JsonConvert.SerializeObject(
      ((IEnumerable<dynamic>)Model.BarChart).Select(x => x.pic).ToList());
  var YLabels = Newtonsoft.Json.JsonConvert.SerializeObject(
      ((IEnumerable<dynamic>)Model.BarChart).Select(x => x.status).ToList());
  var YLabels_Done = Newtonsoft.Json.JsonConvert.SerializeObject(
      ((IEnumerable<dynamic>)Model.BarChart).Select(x => x.status_done).ToList());

  ViewData["Title"] = "PTRSystem";
}
  1. 500 Internal Server Errors mean something wrong in the database query
  • Id overlapped
  • data type incorrect etc...
⚠️ **GitHub.com Fallback** ⚠️