1659384000
この投稿では、.NET 5 用の ASP.NET Core Hero Boilerplate ソリューション テンプレートの使用を開始する方法について説明します。このソリューション テンプレートには、完全に機能する WebAPI と MVC プロジェクトの両方が含まれることに注意してください。
プロジェクトページ –プロジェクトページはこちら
プロジェクト リポジトリ – https://github.com/aspnetcorehero/Boilerplate
Nuget パッケージ – https://www.nuget.org/packages/AspNetCoreHero.Boilerplate/
最初に必要な NuGet パッケージをインストールしましょう。ダウンロードサイズは約10Mbです。コマンド プロンプトを開き、次のコマンドを実行します。
dotnet new --install AspNetCoreHero.Boilerplate
これにより、ソリューション テンプレート全体がマシンにインストールされ、今後のプロジェクトの開始点としてテンプレートを使用できるようになります。ソリューションの生成を開始して構成する方法を見てみましょう。
リポジトリ フォルダー (通常、プロジェクトを作成する任意のフォルダー) に移動します。コマンド プロンプトを開き、ディレクトリを作業フォルダーに変更します。このデモでは、ストア用の Web アプリケーション ソリューションを作成します。StoreManager という名前を付け、場所を「D:\Repository\」として使用します。
cd D:\Repository\
次に、次のコマンドを入力して、必要な名前空間でソリューションを実際に生成します。このデモンストレーションでは、 StoreManagerという名前を使用しています。
dotnet new aspnetcorehero.boilerplate -n StoreManager
以上です!プロジェクトのすべてのレイヤーを備えたソリューションの準備が整いました。Visual Studio でソリューション ファイルを開きましょう。
Visual Studio が必要なすべての NuGet パッケージの復元を完了するまで少し待ちます。
パッケージの復元が完了したら、API プロジェクトと MVC プロジェクトの両方の appsettings.json を開きます。ここで有効な接続文字列を追加していることを確認してください。データベースサーバー(MSSQL)用に設定する方法は次のとおりです。
"ConnectionStrings": {
"ApplicationConnection": "Data Source=LAPTOP-7CS9KHVQ;Initial Catalog=StoreManager;Integrated Security=True;MultipleActiveResultSets=True",
"IdentityConnection": "Data Source=LAPTOP-7CS9KHVQ;Initial Catalog=StoreManager;Integrated Security=True;MultipleActiveResultSets=True"
},
接続文字列が更新されたら、移行を追加してデータベースを更新しましょう。パッケージ マネージャー コンソールを開き、スタートアップ プロジェクトを API プロジェクトとして設定します。デフォルト プロジェクトをインフラストラクチャ プロジェクトとして設定します (下のスクリーンショットで赤くハイライトされた領域を参照してください)。次のコマンドを実行します。
add-migration initial2 -context ApplicationDbContext
add-migration initialIdentity2 -context IdentityContext
移行をソリューション テンプレートに既に追加していることに注意してください。つまり、移行を生成するために上記の手順を実行する必要はありません。ただし、移行ファイルを紛失した場合は、上記のコマンドを使用してそれらを再生成してください。
移行の準備ができたら、データベースを更新しましょう。
update-database -context IdentityContext
update-database -context ApplicationDbContext
すべてが期待どおりに進むと、含まれているすべての ID テーブルなどを含む新しく作成されたデータベースが表示されます。デフォルト データもシードされます。
Awesome Application をビルドして実行するとすぐに、デフォルトのユーザーとロールがデータベースに追加されます。
デフォルトのロールは次のとおりです。
デフォルトのユーザーの資格情報は次のとおりです。
これらのデフォルトの認証情報を使用して、../api/account/authenticate エンドポイントで有効な JWT トークンを生成したり、それらを使用して MVC アプリケーションにログインしたりできます。
認証されたユーザーの JWT トークンを生成する方法は次のとおりです。
トークンを使用して他のリクエストを認証できるようになりました。デフォルトでは、すべてのエンドポイントが保護されており、認証されたユーザーのみがアクセスできることに注意してください。
ここで、.NET 5 MVC プロジェクトについて簡単に見ていきましょう。ログインページが表示されます。認証されたユーザーのみがこの Web アプリケーションにアクセスできることに注意してください。
WebAPI プロジェクトと MVC プロジェクトはどちらも独立したプロジェクトです。MVC プロジェクトは、WEBAPI エンドポイントを消費しません。
デフォルトのユーザーの詳細と資格情報は、ログイン ページのフッターにあります。
スーパークリーンダークモードも搭載!<3
ログインに成功すると、ユーザーはダッシュボードにリダイレクトされます。
前述のように、フローをよりよく理解するために、サンプルの CRUD 操作がプロジェクトに含まれています。この操作は、AJAX 呼び出し、部分ビュー、JSON 結果レンダリング、jQuery Datatable、Select2、およびいくつかの優れた UX に基づいています。単一ページのアプリケーションに近い感覚を提供します。
ブランドを作成することから始めましょう。サイドバーのカタログ ドロップダウン メニューからブランドを開きます。これは jQueryDatable Bootstrap の実装です。きれいに見えますよね?
作成ボタンを作成すると、作成モーダルがポップアップします。ブランド名を入力して保存します。
ほら、それと同じくらい簡単です。次はこのブランドを使って新しい商品を作ってみましょう。
製品ページを開きます。
ダミーの製品詳細を追加して、以前に追加したブランドを選択しましょう。
[保存] をクリックします。終わり。
これは、プロジェクトの私のお気に入りの部分の 1 つである、監査ログです。Entity Framework Core を介して行われたすべての変更をユーザーごとに追跡できる、最小限のインターフェイスとパッケージ。ロギング目的には非常に便利です。
この機能は、他のプロジェクト用にインストールする別の Nuget パッケージとして構築しました。パッケージはこちらから入手してください。このソリューション テンプレートは、すぐに使用できることに注意してください。
ユーザー管理は、このプロジェクトのもう 1 つのハイライトです。スーパー管理者はこの機能にアクセスできます。
Admin、Basic、Superadmin、Moderator は、アプリケーションに組み込まれているデフォルトのロールです。新しい役割も追加できます。
すべての役割には、カスタマイズ可能な権限のセットがあります。スーパー管理者はデフォルトですべての権限を持っています。たとえば、管理者の権限を Brand.Create に設定して、管理者に新しいブランドなどを作成する権限を与えることができます。複数のユーザーに管理者の役割を割り当てることができます。あなたは要点を理解します。
これは、ユーザーがロールにマップされる方法です。
MultiLingual と RTL のサポートが含まれています。
より多くのドキュメントが近日公開予定です。
ソース: https://codewithmukesh.com/blog/aspnet-core-hero-boilerplate-quick-start/
1602560783
In this article, we’ll discuss how to use jQuery Ajax for ASP.NET Core MVC CRUD Operations using Bootstrap Modal. With jQuery Ajax, we can make HTTP request to controller action methods without reloading the entire page, like a single page application.
To demonstrate CRUD operations – insert, update, delete and retrieve, the project will be dealing with details of a normal bank transaction. GitHub repository for this demo project : https://bit.ly/33KTJAu.
Sub-topics discussed :
In Visual Studio 2019, Go to File > New > Project (Ctrl + Shift + N).
From new project window, Select Asp.Net Core Web Application_._
Once you provide the project name and location. Select Web Application(Model-View-Controller) and uncheck HTTPS Configuration. Above steps will create a brand new ASP.NET Core MVC project.
Let’s create a database for this application using Entity Framework Core. For that we’ve to install corresponding NuGet Packages. Right click on project from solution explorer, select Manage NuGet Packages_,_ From browse tab, install following 3 packages.
Now let’s define DB model class file – /Models/TransactionModel.cs.
public class TransactionModel
{
[Key]
public int TransactionId { get; set; }
[Column(TypeName ="nvarchar(12)")]
[DisplayName("Account Number")]
[Required(ErrorMessage ="This Field is required.")]
[MaxLength(12,ErrorMessage ="Maximum 12 characters only")]
public string AccountNumber { get; set; }
[Column(TypeName ="nvarchar(100)")]
[DisplayName("Beneficiary Name")]
[Required(ErrorMessage = "This Field is required.")]
public string BeneficiaryName { get; set; }
[Column(TypeName ="nvarchar(100)")]
[DisplayName("Bank Name")]
[Required(ErrorMessage = "This Field is required.")]
public string BankName { get; set; }
[Column(TypeName ="nvarchar(11)")]
[DisplayName("SWIFT Code")]
[Required(ErrorMessage = "This Field is required.")]
[MaxLength(11)]
public string SWIFTCode { get; set; }
[DisplayName("Amount")]
[Required(ErrorMessage = "This Field is required.")]
public int Amount { get; set; }
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime Date { get; set; }
}
C#Copy
Here we’ve defined model properties for the transaction with proper validation. Now let’s define DbContextclass for EF Core.
#asp.net core article #asp.net core #add loading spinner in asp.net core #asp.net core crud without reloading #asp.net core jquery ajax form #asp.net core modal dialog #asp.net core mvc crud using jquery ajax #asp.net core mvc with jquery and ajax #asp.net core popup window #bootstrap modal popup in asp.net core mvc. bootstrap modal popup in asp.net core #delete and viewall in asp.net core #jquery ajax - insert #jquery ajax form post #modal popup dialog in asp.net core #no direct access action method #update #validation in modal popup
1602564619
User registration and authentication are mandatory in any application when you have little concern about privacy. Hence all most all application development starts with an authentication module. In this article, we will discuss the quickest way to use **ASP.NET Core Identity for User Login and Registration **in a new or existing MVC application.
Sub-topics discussed :
ASP.NET Core Identity is an API, which provides both user interface(UI) and functions for user authentication, registration, authorization, etc. Modules/ APIs like this will really be helpful and fasten the development process. It comes with ASP.NET Core Framework and used in many applications before. Which makes the API more dependable and trustworthy.
ASP.NET Core MVC with user authentication can easily be accomplished using Identity.UI. While creating the MVC project, you just need to select Authentication as Individual User Accounts.
The rest will be handled by ASP.NET Core Identity UI. It already contains razor view pages and backend codes for an authentication system. But that’s not what we want in most of the cases. we want to customize ASP.NET Core Identity as per our requirement. That’s what we do here.
First of all, I will create a brand new ASP.NET Core MVC application without any authentication selected. We could add ASP.NET Core Identity later into the project.
In Visual Studio 2019, Go to File > New > Project (Ctrl + Shift + N). From new project window, select ASP.NET Core Web Application.
Once you provide the project name and location. A new window will be opened as follows, Select _Web Application(Model-View-Controller), _uncheck _HTTPS Configuration _and DO NOT select any authentication method. Above steps will create a brand new ASP.NET Core MVC project.
#asp.net core article #asp.net core #add asp.net core identity to existing project #asp.net core identity in mvc #asp.net core mvc login and registration #login and logout in asp.net core
1583377668
#Asp.net core #Asp.net core mvc #Core #Asp.net core tutorials #Asp.net core with entity framework
1583378723
#Asp.net core #Asp.net core mvc #Core #Asp.net core tutorials #Asp.net core with entity framework
1602564706
In this article, you will learn how to use or integrate WordPress in ASP.NET and Running WordPress on ASP.NET Core, without PHP, or any source files on the server. The following demonstration will show you how to add WordPress as a frontend to an existing ASP.NET Core application step by step.
WordPress is a free, simplest, and most popular open-source content management system to create your own website or blog which is written in PHP and paired up with MySQL. WordPress on .Net Core is possible with peachpie, which is a compiler built on top of the Roslyn platform, it’s a set of runtime and base class libraries and everything that allows compiling a PHP project, a group of PHP files into a regular .net project.
Peachpie allows for seamless both-way interoperability between PHP and .NET applications. In simpler terms, this means that one can have some parts of an application written in PHP, while other modules are written in .NET and everything will work together as one application. Here is the original Repository of the WordPress SDK by PeachPie.
Here are the following steps to run WordPress with ASP.Net Core:-
Step1: Open your Visual Studio IDE and Create a new project – > ASP.NET Core Web Application
Step 2: Select Web Application: A project template for creating an ASP.Net Core application with example ASP.Net Razor Pages Content.
#.net core #asp.net #wordpress asp.net core #wordpress on asp.net core #wordpress with asp.net core