@ -0,0 +1,52 @@
|
||||
import os
|
||||
import json
|
||||
from github import Github
|
||||
|
||||
def update_latest_versions():
|
||||
version = os.environ["GITHUB_REF"].split("/")[-1]
|
||||
|
||||
if "rc" in version:
|
||||
return False
|
||||
|
||||
with open("latest-versions.json", "r") as f:
|
||||
latest_versions = json.load(f)
|
||||
|
||||
latest_versions[0]["version"] = version
|
||||
|
||||
with open("latest-versions.json", "w") as f:
|
||||
json.dump(latest_versions, f, indent=2)
|
||||
|
||||
return True
|
||||
|
||||
def create_pr():
|
||||
g = Github(os.environ["GITHUB_TOKEN"])
|
||||
repo = g.get_repo("abpframework/abp")
|
||||
|
||||
branch_name = f"update-latest-versions-{os.environ['GITHUB_REF'].split('/')[-1]}"
|
||||
base = repo.get_branch("dev")
|
||||
repo.create_git_ref(ref=f"refs/heads/{branch_name}", sha=base.commit.sha)
|
||||
|
||||
# Get the current latest-versions.json file and its sha
|
||||
contents = repo.get_contents("latest-versions.json", ref="dev")
|
||||
file_sha = contents.sha
|
||||
|
||||
# Update the file in the repo
|
||||
repo.update_file(
|
||||
path="latest-versions.json",
|
||||
message=f"Update latest-versions.json to version {os.environ['GITHUB_REF'].split('/')[-1]}",
|
||||
content=open("latest-versions.json", "r").read().encode("utf-8"),
|
||||
sha=file_sha,
|
||||
branch=branch_name,
|
||||
)
|
||||
|
||||
pr = repo.create_pull(title="Update latest-versions.json",
|
||||
body="Automated PR to update the latest-versions.json file.",
|
||||
head=branch_name, base="dev")
|
||||
|
||||
pr.create_review_request(reviewers=["ebicoglu", "gizemmutukurt", "skoc10"])
|
||||
|
||||
if __name__ == "__dev__":
|
||||
should_create_pr = update_latest_versions()
|
||||
if should_create_pr:
|
||||
create_pr()
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
name: Update Latest Versions
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
update-versions:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install PyGithub
|
||||
|
||||
- name: Update latest-versions.json and create PR
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
python .github/scripts/update_versions.py
|
||||
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 613 KiB After Width: | Height: | Size: 613 KiB |
|
Before Width: | Height: | Size: 523 KiB After Width: | Height: | Size: 523 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 329 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 234 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 150 KiB |
|
After Width: | Height: | Size: 48 KiB |
@ -0,0 +1,118 @@
|
||||
# 💻 How to Optimize Your ASP.NET Application for Improved Performance 🚀
|
||||
|
||||
If you want your ASP.NET application to perform well, you need to optimize it for speed, responsiveness, and user experience. Performance optimization is critical for factors like fast page load times, improved response efficiency, and happy users. In this article, I'll provide several tips and tricks to help you optimize performance in ASP.NET Core.
|
||||
|
||||
## 🚀 Use Response Compression in Your ASP.NET Application
|
||||
You can use ASP.NET Core's built-in response compression middleware to compress the response data and reduce the amount of data that needs to be transferred over the network. To use response compression, add the following code to your application's Startup.cs file:
|
||||
|
||||
```csharp
|
||||
services.AddResponseCompression(options =>
|
||||
{
|
||||
options.EnableForHttps = true;
|
||||
});
|
||||
|
||||
app.UseResponseCompression();
|
||||
```
|
||||
|
||||
## 🖼️ Optimize Images in Your ASP.NET Application:
|
||||
|
||||
Images can be a major contributor to page bloat and slow load times. Here are some tips to optimize images:
|
||||
|
||||
🖌️ Use a tool like ImageOptim or Kraken.io to compress and optimize images.
|
||||
|
||||
🖼️ Specify the width and height of images in HTML so the browser can allocate space for them before they load.
|
||||
|
||||
📝 Use alt attributes to provide descriptive text for images, which can improve accessibility and also help with SEO.
|
||||
|
||||
📜 Use lazy loading for images that are below the fold, meaning they're not visible on the initial screen view. You can use libraries like Vanilla LazyLoad to implement lazy loading.
|
||||
|
||||
📱 Use responsive images to serve different image sizes to different devices. This can improve page load times by reducing the size of images that are displayed on smaller devices.
|
||||
|
||||
💻 Example:
|
||||
|
||||
```html
|
||||
<picture>
|
||||
<source media="(min-width: 650px)" data-srcset="image.webp">
|
||||
<source media="(min-width: 465px)" data-srcset="image_small.webp">
|
||||
<img src="placeholder.png" data-src="image.webp" alt="Image" width="100" height="100" class="lazy" />
|
||||
</picture>
|
||||
```
|
||||
|
||||
```javascript
|
||||
var lazyLoadInstance = new LazyLoad();
|
||||
```
|
||||
|
||||
## 🧱 Optimize HTML in Your ASP.NET Application:
|
||||
|
||||
The structure and organization of HTML can affect the page speed. Here are some tips to optimize HTML:
|
||||
|
||||
📝 Use the heading tags (h1, h2, h3, etc.) in a logical and sequential order.
|
||||
|
||||
🔩 Use the "defer" attribute for script tags that don't need to be executed immediately. This can improve the page load times by delaying the execution of scripts until after the page has rendered.
|
||||
|
||||
🔩 Use the "async" attribute for script tags that can be executed asynchronously. This can further improve the page load times by allowing scripts to be downloaded and executed simultaneously.
|
||||
|
||||
🧱 Use semantic HTML elements (like nav, section, and article) to provide additional structure and meaning to the page.
|
||||
|
||||
## 🎨 Optimize CSS and JavaScript in Your ASP.NET Application:
|
||||
|
||||
CSS and JavaScript files can be a major contributor to the page load times. Here are some tips to optimize CSS and JavaScript in your ASP.NET application:
|
||||
|
||||
🔨 Minify and concatenate CSS and JavaScript files to reduce their size.
|
||||
|
||||
🔩 Use the "defer" or "async" attributes for script tags to delay or asynchronously load scripts.
|
||||
|
||||
## 🔡 Use system fonts in Your ASP.NET Application:
|
||||
|
||||
Loading custom fonts can be slow and increase page load times. Using system fonts can improve page speed by allowing the browser to use fonts that are already installed on the user's device.
|
||||
|
||||
## 🖼️ Use Placeholders and Progress Indicators in Your ASP.NET Application:
|
||||
|
||||
To improve the perceived performance of your website, you can use placeholders and progress indicators for slow-loading sections of your page. You can use JavaScript to load these sections after the initial page load.
|
||||
|
||||
💻 Example:
|
||||
|
||||
```html
|
||||
|
||||
<div id="placeholder" data-url="/slow-loading-content">
|
||||
<p>Loading...</p>
|
||||
</div>
|
||||
```
|
||||
|
||||
```javascript
|
||||
const placeholder = document.querySelector('#placeholder');
|
||||
fetch(placeholder.dataset.url)
|
||||
.then(response => response.text())
|
||||
.then(html => placeholder.innerHTML = html);
|
||||
```
|
||||
|
||||
## 🔗 Use the Appropriate Link Text and ARIA Labels:
|
||||
|
||||
When using links, use appropriate link texts that accurately describe the content of the linked page. This can improve the accessibility and also help with SEO.
|
||||
|
||||
ARIA labels should also be used to provide additional context for links. This can also improve the accessibility and help with SEO.
|
||||
|
||||
💻 Example:
|
||||
|
||||
```html
|
||||
<a href="https://example.com/" aria-label="Go to Example">Example</a>
|
||||
<a href="https://example.com/" aria-label="Go to Another Example">Another Example</a>
|
||||
```
|
||||
|
||||
## 🌐 Optimize the Third-party Resources in Your ASP.NET Application:
|
||||
|
||||
Third-party resources like social media widgets and advertising scripts can slow down the page load times. Here are some tips to optimize third-party resources:
|
||||
|
||||
🔩 Use asynchronous scripts when possible.
|
||||
|
||||
🔍 Only load third-party resources that are necessary for the page.
|
||||
|
||||
By following these optimization techniques, you can significantly improve the page speed of your ASP.NET Core web application.
|
||||
|
||||
## What is ABP Framework?
|
||||
|
||||
ABP Framework offers an opinionated architecture to build enterprise software solutions with ASP.NET Core best practices on top of the .NET and the ASP.NET Core platforms. It provides the fundamental web application infrastructure, production-ready dotnet startup templates, modules, asp.net core ui themes, tooling, guides and documentation to implement that ASP.NET core architecture properly and automate the details and repetitive work as much as possible.
|
||||
|
||||
If you are starting a new ASP.NET Core project, try [abp.io](https://abp.io/) now...
|
||||
|
||||
**IT IS FREE AND OPEN-SOURCE!**
|
||||
@ -0,0 +1,325 @@
|
||||
# Convert Create/Edit Modals to Page
|
||||
|
||||
In this document we will explain how to convert the BookStore's Books create & edit modals to regular Angular component pages.
|
||||
|
||||
## Before
|
||||
|
||||

|
||||
|
||||
## After
|
||||
|
||||

|
||||
|
||||
# BooksComponent
|
||||
|
||||
This is the main component of the books management. The create & update operations are done in this page. So we'll remove the create & update operations from this page and move a separate angular component for each operation. Each component will be a page.
|
||||
|
||||
- Remove the Create & Update modal on template
|
||||
|
||||

|
||||
|
||||
- Modify the **NewBook** button with a link to the **CreateBookComponent** page.
|
||||
|
||||
```html
|
||||
<button
|
||||
*abpPermission="'BookStore.Books.Create'"
|
||||
id="create"
|
||||
class="btn btn-primary"
|
||||
type="button"
|
||||
[routerLink]="['create']"
|
||||
>
|
||||
<i class="fa fa-plus me-1"></i>
|
||||
<span>{{ '::NewBook' | abpLocalization }}</span>
|
||||
</button>
|
||||
```
|
||||
|
||||
- Modify the **Edit** button with a link to the **EditBookComponent** page.
|
||||
|
||||
```html
|
||||
<button
|
||||
*abpPermission="'BookStore.Books.Edit'"
|
||||
ngbDropdownItem
|
||||
[routerLink]="['edit', row.id]"
|
||||
>
|
||||
{{ '::Edit' | abpLocalization }}
|
||||
</button>
|
||||
```
|
||||
|
||||
- Remove all unused methods and variables in the `BookComponent` except the **book** variable, the **ngOnInit** and **delete** methods.
|
||||
|
||||
|
||||

|
||||
|
||||
- Also we can clear unncessary imports
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
# CreateBookComponent Page
|
||||
|
||||
Create a new component by the name `create-book` in your project.
|
||||
```bash
|
||||
yarn ng g c book/create-book --skip-tests --style=none
|
||||
```
|
||||
|
||||
- `create-book.component.html`
|
||||
|
||||
```html
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form [formGroup]="form" (ngSubmit)="save()">
|
||||
<div class="form-group">
|
||||
<label for="author-id">Author</label><span> * </span>
|
||||
<select class="form-control" id="author-id" formControlName="authorId">
|
||||
<option [ngValue]="null">Select author</option>
|
||||
<option [ngValue]="author.id" *ngFor="let author of authors$ | async">
|
||||
{{ author.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<label for="book-name">Name</label><span> * </span>
|
||||
<input type="text" id="book-name" class="form-control" formControlName="name" autofocus />
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<label for="book-price">Price</label><span> * </span>
|
||||
<input type="number" id="book-price" class="form-control" formControlName="price" />
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<label for="book-type">Type</label><span> * </span>
|
||||
<select class="form-control" id="book-type" formControlName="type">
|
||||
<option [ngValue]="null">Select a book type</option>
|
||||
<option [ngValue]="type.value" *ngFor="let type of bookTypes">
|
||||
{{ '::Enum:BookType.' + type.value | abpLocalization }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<label>Publish date</label><span> * </span>
|
||||
<input
|
||||
#datepicker="ngbDatepicker"
|
||||
class="form-control"
|
||||
name="datepicker"
|
||||
formControlName="publishDate"
|
||||
ngbDatepicker
|
||||
(click)="datepicker.toggle()"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="pt-2">
|
||||
<button type="button" class="btn btn-secondary m-1" [routerLink]="['/books']">
|
||||
{{ '::Cancel' | abpLocalization }}
|
||||
</button>
|
||||
|
||||
<button class="btn btn-primary">
|
||||
<i class="fa fa-check mr-1"></i>
|
||||
{{ '::Save' | abpLocalization }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
- `create-book.component.ts`
|
||||
|
||||
```ts
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { map } from 'rxjs';
|
||||
import { NgbDateNativeAdapter, NgbDateAdapter } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { BookService, bookTypeOptions } from '@proxy/books';
|
||||
|
||||
const { required } = Validators;
|
||||
|
||||
@Component({
|
||||
selector: 'app-create-book',
|
||||
templateUrl: './create-book.component.html',
|
||||
providers: [{ provide: NgbDateAdapter, useClass: NgbDateNativeAdapter }],
|
||||
})
|
||||
export class CreateBookComponent {
|
||||
//inject() function came with Angular v14, detail: https://angular.io/api/core/inject
|
||||
private readonly router = inject(Router);
|
||||
private readonly fb = inject(FormBuilder);
|
||||
private readonly bookService = inject(BookService);
|
||||
|
||||
form: FormGroup;
|
||||
authors$ = this.bookService.getAuthorLookup().pipe(map(({ items }) => items));
|
||||
bookTypes = bookTypeOptions;
|
||||
|
||||
private buildForm() {
|
||||
this.form = this.fb.group({
|
||||
authorId: [null, required],
|
||||
name: [null, required],
|
||||
type: [null, required],
|
||||
publishDate: [undefined, required],
|
||||
price: [null, required],
|
||||
});
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.buildForm();
|
||||
}
|
||||
|
||||
save() {
|
||||
if (this.form.invalid) return;
|
||||
|
||||
this.bookService.create(this.form.value).subscribe(() => {
|
||||
this.router.navigate(['/books']);
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# EditBookComponent Page
|
||||
|
||||
Create a new component by the name **edit-book** in your project.
|
||||
|
||||
```bash
|
||||
yarn ng g c book/edit-book --skip-tests --style=none
|
||||
```
|
||||
|
||||
- `edit-book.component.html`
|
||||
|
||||
```html
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form *ngIf="form" [formGroup]="form" (ngSubmit)="save()">
|
||||
<div class="form-group">
|
||||
<label for="author-id">Author</label><span> * </span>
|
||||
<select class="form-control" id="author-id" formControlName="authorId">
|
||||
<option [ngValue]="null">Select author</option>
|
||||
<option [ngValue]="author.id" *ngFor="let author of authors$ | async">
|
||||
{{ author.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<label for="book-name">Name</label><span> * </span>
|
||||
<input type="text" id="book-name" class="form-control" formControlName="name" autofocus />
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<label for="book-price">Price</label><span> * </span>
|
||||
<input type="number" id="book-price" class="form-control" formControlName="price" />
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<label for="book-type">Type</label><span> * </span>
|
||||
<select class="form-control" id="book-type" formControlName="type">
|
||||
<option [ngValue]="null">Select a book type</option>
|
||||
<option [ngValue]="type.value" *ngFor="let type of bookTypes">
|
||||
{{ '::Enum:BookType.' + type.value | abpLocalization }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<label>Publish date</label><span> * </span>
|
||||
<input
|
||||
#datepicker="ngbDatepicker"
|
||||
class="form-control"
|
||||
name="datepicker"
|
||||
formControlName="publishDate"
|
||||
ngbDatepicker
|
||||
(click)="datepicker.toggle()"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="pt-2">
|
||||
<button type="button" class="btn btn-secondary m-1" [routerLink]="['/books']">
|
||||
{{ '::Cancel' | abpLocalization }}
|
||||
</button>
|
||||
|
||||
<button class="btn btn-primary">
|
||||
<i class="fa fa-check mr-1"></i>
|
||||
{{ '::Save' | abpLocalization }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
- `edit-book.component.ts`
|
||||
|
||||
```ts
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { filter, map, switchMap, tap } from 'rxjs';
|
||||
import { NgbDateNativeAdapter, NgbDateAdapter } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { BookDto, BookService, bookTypeOptions } from '@proxy/books';
|
||||
|
||||
const { required } = Validators;
|
||||
|
||||
@Component({
|
||||
selector: 'app-edit-book',
|
||||
templateUrl: './edit-book.component.html',
|
||||
providers: [{ provide: NgbDateAdapter, useClass: NgbDateNativeAdapter }],
|
||||
})
|
||||
export class EditBookComponent {
|
||||
//inject() function came with Angular v14, detail: https://angular.io/api/core/inject
|
||||
private readonly router = inject(Router);
|
||||
private readonly activatedRoute = inject(ActivatedRoute);
|
||||
private readonly fb = inject(FormBuilder);
|
||||
private readonly bookService = inject(BookService);
|
||||
|
||||
id: string;
|
||||
form: FormGroup;
|
||||
authors$ = this.bookService.getAuthorLookup().pipe(map(({ items }) => items));
|
||||
bookTypes = bookTypeOptions;
|
||||
|
||||
private buildForm(book: BookDto): void {
|
||||
this.form = this.fb.group({
|
||||
authorId: [book.authorId, required],
|
||||
name: [book.name, required],
|
||||
type: [book.type, required],
|
||||
publishDate: [new Date(book.publishDate), required],
|
||||
price: [book.price, required],
|
||||
});
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.activatedRoute.params
|
||||
.pipe(
|
||||
filter(params => params.id),
|
||||
tap(({ id }) => (this.id = id)),
|
||||
switchMap(({ id }) => this.bookService.get(id)),
|
||||
tap(book => this.buildForm(book))
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
save(): void {
|
||||
if (this.form.invalid) return;
|
||||
|
||||
this.bookService.update(this.id, this.form.value).subscribe(() => {
|
||||
this.router.navigate(['/books']);
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# Update BookRoutingModule
|
||||
Finally add 2 items to the routes array in the `book-routing.module.ts`
|
||||
```ts
|
||||
import { CreateBookComponent } from './create-book/create-book.component';
|
||||
import { EditBookComponent } from './edit-book/edit-book.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: BookComponent, canActivate: [AuthGuard, PermissionGuard] },
|
||||
{ path: 'create', component: CreateBookComponent },
|
||||
{ path: 'edit/:id', component: EditBookComponent },
|
||||
];
|
||||
```
|
||||
|
||||
|
||||
You can check the following commit for more details: https://github.com/abpframework/abp-samples/commit/351ad5e093036702edbb15169968935496afea0e
|
||||
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 129 KiB |
|
After Width: | Height: | Size: 291 KiB |
|
After Width: | Height: | Size: 678 KiB |
@ -0,0 +1,52 @@
|
||||
# Getting Started
|
||||
|
||||
````json
|
||||
//[doc-params]
|
||||
{
|
||||
"UI": ["MVC", "Blazor", "BlazorServer", "NG"],
|
||||
"DB": ["EF", "Mongo"]
|
||||
}
|
||||
````
|
||||
|
||||
> This document assumes that you prefer to use **{{ UI_Value }}** as the UI framework and **{{ DB_Value }}** as the database provider. For other options, please change the preference on top of this document.
|
||||
|
||||
## Create a New Project
|
||||
|
||||
We will use the ABP CLI to create a new ABP project.
|
||||
|
||||
> You can also use the ABP CLI Command Generator on the [ABP Framework website](https://abp.io/get-started) by easily selecting all options from the page.
|
||||
|
||||
Use the `new` command of the ABP CLI to create a new project:
|
||||
|
||||
````shell
|
||||
abp new Acme.BookStore -t app-nolayers{{if UI == "NG"}} -u angular{{else if UI == "Blazor"}} -u blazor{{else if UI == "BlazorServer"}} -u blazor-server{{end}}{{if DB == "Mongo"}} -d mongodb{{end}}
|
||||
````
|
||||
|
||||
*You can use different level of namespaces; e.g. BookStore, Acme.BookStore or Acme.Retail.BookStore.*
|
||||
|
||||
> [ABP CLI document](./CLI.md) covers all of the available commands and options.
|
||||
|
||||
## The Solution Structure
|
||||
|
||||
The solution structure is based on the [Single-Layer Startup Template](Startup-Templates/Application-Single-Layer.md) where everything is in one project instead of the [Domain Driven Design](Domain-Driven-Design.md). You can check its [documentation](Startup-Templates/Application-Single-Layer.md) for more details.
|
||||
|
||||
{{ if DB == "Mongo" }}
|
||||
|
||||
## MongoDB Transactions
|
||||
|
||||
The [startup template](Startup-templates/Index.md) **disables** transactions in the `.MongoDB` project by default. If your MongoDB server supports transactions, you can enable it in the *YourProjectModule* class's `ConfigureMongoDB` method:
|
||||
|
||||
```csharp
|
||||
Configure<AbpUnitOfWorkDefaultOptions>(options =>
|
||||
{
|
||||
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Enabled; //or UnitOfWorkTransactionBehavior.Auto
|
||||
});
|
||||
```
|
||||
|
||||
> Or you can delete that code since `Auto` is already the default behavior.
|
||||
|
||||
{{ end }}
|
||||
|
||||
## Next Step
|
||||
|
||||
* [Running the solution](Getting-Started-Running-Solution-Single-Layer.md)
|
||||
@ -0,0 +1,8 @@
|
||||
# Getting Started: Overall
|
||||
|
||||
## Select the Solution Architecture
|
||||
|
||||
This tutorial has multiple versions. Please select the one that fits you the best:
|
||||
|
||||
* **[Single-Layer Solution](Getting-Started-Single-Layered.md)**: Creates a single-project solution. Recommended for building an application with a **simpler and easy to understand** architecture.
|
||||
* **[Layered Solution Architecture](Getting-Started.md)**: A fully layered (multiple projects) solution based on [Domain Driven Design](Domain-Driven-Design.md) practices. Recommended for long-term projects that need a **maintainable and extensible** codebase.
|
||||
@ -0,0 +1,98 @@
|
||||
# Getting Started
|
||||
|
||||
````json
|
||||
//[doc-params]
|
||||
{
|
||||
"UI": ["MVC", "Blazor", "BlazorServer", "NG"],
|
||||
"DB": ["EF", "Mongo"]
|
||||
}
|
||||
````
|
||||
|
||||
> This document assumes that you prefer to use **{{ UI_Value }}** as the UI framework and **{{ DB_Value }}** as the database provider. For other options, please change the preference on top of this document.
|
||||
|
||||
## Create the Database
|
||||
|
||||
### Connection String
|
||||
|
||||
Check the **connection string** in the `appsettings.json` file under the `YourProject` project.
|
||||
|
||||
{{ if DB == "EF" }}
|
||||
|
||||
````json
|
||||
"ConnectionStrings": {
|
||||
"Default": "Server=(LocalDb)\MSSQLLocalDB;Database=BookStore;Trusted_Connection=True"
|
||||
}
|
||||
````
|
||||
|
||||
> **About the Connection Strings and Database Management Systems**
|
||||
>
|
||||
> The solution is configured to use **Entity Framework Core** with **MS SQL Server** by default. However, if you've selected another DBMS using the `-dbms` parameter on the ABP CLI `new` command (like `-dbms MySQL`), the connection string might be different for you.
|
||||
>
|
||||
> EF Core supports [various](https://docs.microsoft.com/en-us/ef/core/providers/) database providers and you can use any supported DBMS. See [the Entity Framework integration document](Entity-Framework-Core.md) to learn how to [switch to another DBMS](Entity-Framework-Core-Other-DBMS.md) if you need later.
|
||||
|
||||
{{ else if DB == "Mongo" }}
|
||||
|
||||
````json
|
||||
"ConnectionStrings": {
|
||||
"Default": "mongodb://localhost:27017/BookStore"
|
||||
}
|
||||
````
|
||||
|
||||
The solution is configured to use **MongoDB** in your local computer, so you need to have a MongoDB server instance up and running or change the connection string to another MongoDB server.
|
||||
|
||||
{{ end }}
|
||||
|
||||
### Seed Initial Data
|
||||
|
||||
Before running the application, you need to create the database and seed the initial data. To do that, you can run the following command in the directory of your project (in the same folder of the `.csproj` file):
|
||||
|
||||
```bash
|
||||
dotnet run --migrate-database
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Run the Application
|
||||
|
||||
{{if UI=="MVC" || UI=="BlazorServer"}}
|
||||
|
||||
Running the application is pretty straight-forward, you can run the application with any IDE that supports .NET or by running the `dotnet run` CLI command in the directory of your project:
|
||||
|
||||
{{else if UI=="Blazor"}}
|
||||
|
||||
Running the application is pretty straight-forward, you just need to run the `TodoApp.Host` application with any IDE that supports .NET or by running the `dotnet run` CLI command in the directory of your project.
|
||||
|
||||
> **Note:** The `host` application hosts and serves the `blazor` application. Therefore, you should run the `host` application only.
|
||||
|
||||
After the application runs, open the application in your default browser.
|
||||
|
||||
{{else if UI=="NG"}}
|
||||
|
||||
The solution has two main applications:
|
||||
|
||||
* `TodoApp` (in the .NET solution) hosts the server-side HTTP API, so the Angular application can consume it. (server-side application)
|
||||
* `angular` folder contains the Angular application. (client-side application)
|
||||
|
||||
Firstly, run the `TodoApp` project in your favorite IDE (or run the `dotnet run` CLI command on your project directory) to see the server-side HTTP API on [Swagger UI](https://swagger.io/tools/swagger-ui/).
|
||||
|
||||

|
||||
|
||||
You can explore and test your HTTP API with this UI. If it works, then we can run the Angular client application.
|
||||
|
||||
You can run the application using the following (or `yarn start`) command:
|
||||
|
||||
````bash
|
||||
npm start
|
||||
````
|
||||
|
||||
This command takes time, but eventually runs and opens the application in your default browser.
|
||||
|
||||
{{end}}
|
||||
|
||||
After running the project, the index page should be seen as below:
|
||||
|
||||

|
||||
|
||||
Enter **admin** as the username and **1q2w3E*** as the password to login to the application. The application is up and running. You can start developing your application based on this startup template.
|
||||
|
||||

|
||||
@ -0,0 +1,49 @@
|
||||
# Getting Started
|
||||
|
||||
````json
|
||||
//[doc-params]
|
||||
{
|
||||
"UI": ["MVC", "Blazor", "BlazorServer", "NG"],
|
||||
"DB": ["EF", "Mongo"]
|
||||
}
|
||||
````
|
||||
|
||||
> This document assumes that you prefer to use **{{ UI_Value }}** as the UI framework and **{{ DB_Value }}** as the database provider. For other options, please change the preference on top of this document.
|
||||
|
||||
## Setup Your Development Environment
|
||||
|
||||
First things first! Let's setup your development environment before creating the project.
|
||||
|
||||
### Pre-Requirements
|
||||
|
||||
The following tools should be installed on your development machine:
|
||||
|
||||
* An IDE (e.g. [Visual Studio](https://visualstudio.microsoft.com/vs/)) that supports [.NET 7.0+](https://dotnet.microsoft.com/download/dotnet) development.
|
||||
{{ if UI != "Blazor" }}
|
||||
* [Node v16 or v18](https://nodejs.org/)
|
||||
* [Yarn v1.20+ (not v2)](https://classic.yarnpkg.com/en/docs/install) <sup id="a-yarn">[1](#f-yarn)</sup> or npm v6+ (already installed with Node)
|
||||
{{ end }}
|
||||
|
||||
{{ if UI != "Blazor" }}
|
||||
|
||||
<sup id="f-yarn"><b>1</b></sup> _Yarn v2 works differently and is not supported._ <sup>[↩](#a-yarn)</sup>
|
||||
|
||||
{{ end }}
|
||||
|
||||
### Install the ABP CLI
|
||||
|
||||
[ABP CLI](./CLI.md) is a command line interface that is used to automate some common tasks for ABP based solutions. First, you need to install the ABP CLI using the following command:
|
||||
|
||||
````shell
|
||||
dotnet tool install -g Volo.Abp.Cli
|
||||
````
|
||||
|
||||
If you've already installed, you can update it using the following command:
|
||||
|
||||
````shell
|
||||
dotnet tool update -g Volo.Abp.Cli
|
||||
````
|
||||
|
||||
## Next Step
|
||||
|
||||
* [Creating a new solution](Getting-Started-Create-Solution-Single-Layer.md)
|
||||
@ -0,0 +1,17 @@
|
||||
# Getting Started
|
||||
|
||||
````json
|
||||
//[doc-params]
|
||||
{
|
||||
"UI": ["MVC", "Blazor", "BlazorServer", "NG"],
|
||||
"DB": ["EF", "Mongo"]
|
||||
}
|
||||
````
|
||||
|
||||
> This document assumes that you prefer to use **{{ UI_Value }}** as the UI framework and **{{ DB_Value }}** as the database provider. For other options, please change the preference on top of this document.
|
||||
|
||||
This tutorial explains how to **create and run** a new Single-Layered web application using the ABP Framework. Follow the steps below:
|
||||
|
||||
1. [Setup your development environment](Getting-Started-Setup-Environment-Single-Layer.md)
|
||||
2. [Creating a new solution](Getting-Started-Create-Solution-Single-Layer.md)
|
||||
3. [Running the solution](Getting-Started-Running-Solution-Single-Layer.md)
|
||||
@ -0,0 +1,45 @@
|
||||
# Security Headers
|
||||
|
||||
ABP Framework allows you to add frequently used security headers into your application. The following security headers will be added as response headers to your application if you use the `UseAbpSecurityHeaders` middleware:
|
||||
|
||||
* `X-Content-Type-Options`: Tells the browser to not try and guess what a mime-type of a resource might be, and to just take what mime-type the server has returned.
|
||||
* `X-XSS-Protection`: This is a feature of Internet Explorer, Chrome, and Safari that stops pages from loading when they detect reflected cross-site scripting (XSS) attacks.
|
||||
* `X-Frame-Options`: This header can be used to indicate whether or not a browser should be allowed to render a page in a `<iframe>` tag. By specifying this header value as *SAMEORIGIN*, you can make it displayed in a frame on the same origin as the page itself.
|
||||
* `Content-Security-Policy`: This response header allows you to restrict which resources (such as JavaScript, CSS, images, manifests, etc.) can be loaded, and the URLs that they can be loaded from. This security header will only be added if you configure the `AbpSecurityHeadersOptions` class and enable it.
|
||||
|
||||
## Configuration
|
||||
|
||||
### AbpSecurityHeadersOptions
|
||||
|
||||
`AbpSecurityHeadersOptions` is the main class to enable the `Content-Security-Policy` header, define its value and set other security headers that you want to add to your application.
|
||||
|
||||
**Example:**
|
||||
|
||||
```csharp
|
||||
Configure<AbpSecurityHeadersOptions>(options =>
|
||||
{
|
||||
options.UseContentSecurityPolicyHeader = true; //false by default
|
||||
options.ContentSecurityPolicyValue = "object-src 'none'; form-action 'self'; frame-ancestors 'none'";
|
||||
|
||||
//adding additional security headers
|
||||
options.Headers["Referrer-Policy"] = "no-referrer";
|
||||
});
|
||||
```
|
||||
|
||||
> If the header is the same, the additional security headers you defined take precedence over the default security headers. In other words, it overrides the default security headers' values.
|
||||
|
||||
## Security Headers Middleware
|
||||
|
||||
Security Headers middleware is an ASP.NET Core request pipeline [middleware](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware) that adds pre-defined security headers to your application, including `X-Content-Type-Options`, `X-XSS-Protection`, and `X-Frame-Options`. Additionally, this middleware also includes those unique security headers in your application if you configure the `AbpSecurityHeadersOptions` as mentioned above.
|
||||
|
||||
**Example:**
|
||||
|
||||
```csharp
|
||||
app.UseAbpSecurityHeaders();
|
||||
```
|
||||
|
||||
> You can add this middleware into the `OnApplicationInitialization` method of your module class to register it to the request pipeline. This middleware is already configured in the [ABP Commercial Startup Templates](https://docs.abp.io/en/commercial/latest/startup-templates/index), so you don't need to manually add it if you are using one of these startup templates.
|
||||
|
||||
After that, you have registered the `UseAbpSecurityHeaders` middleware into the request pipeline, the defined security headers will be shown in the response headers as in the figure below:
|
||||
|
||||

|
||||
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 256 KiB |
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Volo.Abp.Cli.ProjectBuilding.Building;
|
||||
|
||||
namespace Volo.Abp.Cli.ProjectBuilding.Templates;
|
||||
|
||||
public class RandomizeAuthServerPassPhraseStep : ProjectBuildPipelineStep
|
||||
{
|
||||
protected const string DefaultPassPhrase = "00000000-0000-0000-0000-000000000000";
|
||||
|
||||
public override void Execute(ProjectBuildContext context)
|
||||
{
|
||||
var files = context.Files
|
||||
.Where(x => !x.IsDirectory)
|
||||
.Where(x => x.Content.IndexOf(DefaultPassPhrase, StringComparison.InvariantCultureIgnoreCase) >= 0)
|
||||
.ToList();
|
||||
|
||||
var randomPassPhrase = Guid.NewGuid().ToString("D");
|
||||
foreach (var file in files)
|
||||
{
|
||||
file.NormalizeLineEndings();
|
||||
|
||||
var lines = file.GetLines();
|
||||
for (var i = 0; i < lines.Length; i++)
|
||||
{
|
||||
if (lines[i].Contains(DefaultPassPhrase))
|
||||
{
|
||||
lines[i] = lines[i].Replace(DefaultPassPhrase, randomPassPhrase);
|
||||
}
|
||||
}
|
||||
|
||||
file.SetLines(lines);
|
||||
}
|
||||
}
|
||||
}
|
||||