- UseDevelopeerExceptionPage
- Captures synchronous and asynchronous System.Exception instances from the pipeline and generates HTML error responses.
- UseHsts
- Adds middleware for using HSTS, which adds the Strict-Transport-Security header.
- UseRouting
- Adds middleware that defines a point in the pipeline where routing decisions are made and must be combined with a call to UseEndpoints where the processing is then executed. This means that for our code, any URL paths that match / or /index or /page will be mapped to Razor Pages and match on /hello will be mapped to the anonymous delegate. Any other URL paths will be passed on to the next delegate for matching, for example, static files. This is why, although it looks like the mapping for Razor Pages and /hello happen after static files in the pipeline, they actually take priority because the call to UseRouting happens before UseStaticFiles.
- UseHttpsRedirection
- Adds middleware for redirecting HTTPS requests to HTTPS, so in our code request for htttp://lcocalhost:5000 would be modified to https://localhost:5001
- UseDefaultFiles
- Adds middleware that enables default file mapping on the current path, so in our code it would identify files such as index.html
- UseStaticFiles
- Adds middleware that looks in wwwroot for static files to return in the HTTP response.
- UseEndpoints
- Adds middleware to execute to generate response from decision made earlier in the pipeline. Two endpoints are added, as shown in the following sub-list.
- MapRazorPages
- Adds middleware that will map URL paths such as /suppliers to Razor Page file in the /Pages folder named suppliers.cshtml and return the result as the HTTP response.
- MapGet
- Adds middleware that will map URL paths such as /hello to an inline delegate writes plain test directly to the HTTP response.
Saturday, November 19, 2022
asp.net middleware extension methods
run, map and use methods in asp.net
Run
Adds a middleware delegate that determinates the pipeline by immediately returning a response instead of calling the next middleware delegate.
Map
Adds a middleware delegate that creates a branch in the pipeline when there is a matching request usually based on a URL path like /hello
Use
Adds a middleware delegate that forms part of the pipeline so it can decide if it wants to pass the request to the next delegate in the pipeline and it can modify the request and response before and after the next delegate.
Registering services in the ConfigureServices method
AddMvcCore
minimum set of services to route and invoke controller. most websites will need more configuration than this.
AddAuthorization
authentication and authorization services.
AddDataAnnotations
mvc data annotations service.
AddCacheTagHelper
mvc cache tag helper service
AddRazorPages
razor pages service includes the razor view engine. commonly used in simple website projects. it calls the following additional methods.
- AddMvcCore
- AddAuthorization
- AddDataAnnotations
- AddCacheTagHelper
- AddApiExplorer
- AddCors
- AddFormaterMappings
AddViews
support for .cshtml views including default conventions.
AddRazorViewEngine
support for razor view engine including proessing the @symbol.
AddControllerWithViews
controller, views, and pages services. commonly used in ASP.NET Core MVC projects. it calls the following additional methods.
- AddMvcCore
- AddAuthorization
- AddDataAnnotations
- AddCacheTagHelper
- AddApiExplorer
- AddCors
- AddFormattermappings
- AddViews
- AddRazorViewEngine
AddMvc
similar to AddControllerWithViews, but you should only use it for backward compatibility.
AddContext<T>
your DbContext type and its optional DbContextOptions<TContext>
AddCustomContext
a custom extension method we created to make it easier to register the NorthwindContext class for either SQLite or SQL Server based on the project referenced.
Friday, November 18, 2022
The Object Oriented Thought Process 5th Edition
Object Wrappers
object wrappers are object-oriented code that includes other code inside for example. you can take structured code (such as loops and conditions) and wrap it inside an object to make it look like an object. You can also use object wrappers to wrap functionality such as security features, nonportable hardware features, and so on.
sound class design guidelines
keep in mind that it is possible to create poorly designed oo classes that do not restrict access to class attributes. The bottom line is that you can design bad code just as efficiently with oo design as with any other programming methodology.
in general, objects should not manipulate the internal data of other objects.
Wednesday, November 9, 2022
How to pass data to parent in vue.js
This is how we can pass data from child to parent component in vue js.
- child component should emit a custom event which pass data.
- parent component should listen for it via v-on
Tuesday, November 8, 2022
How to install and initialize vue js?
INSTALLING VUE JS
- Using Scripts
- Development Scripts
- Production Scripts
- CLI
- npm
- npm install --global @vue/cli
- yarn
- yarn global add @vue/cli
How to create database context class and adding tables to it? ASP.NET Core 6
CODE:
namespace projectnamespace;
public class Northwind : DbContext
{
var DataProvider="SQLite";
string path = Path.Combine(
Environment.CurrentDirectory, "Northwind.db");
WriteLine($"Using {path} database file.");
optionsBuilder.UseSqlite($"Filename={path}");
} else
{
string connection = "Data Source=.;" +
"Initial Catalog=Northwind;" +
"Integrated Security=true;" +
"MultipleActiveResultSets=true;";
optionsBuilder.UseSqlServer(connection);
Subscribe to:
Posts (Atom)
methods available in Dapper
Dapper is a micro ORM library for .NET and .NET Core applications that allows you to execute SQL queries and map the results to objects. D...
-
Object Wrappers object wrappers are object-oriented code that includes other code inside for example. you can take structured code (such as ...
-
AddMvcCore minimum set of services to route and invoke controller. most websites will need more configuration than this. AddAuthorization au...
-
Install JSON Server npm install -g json-server Create a db.json file with some data { " posts " : [ { " id " :...