1657548803
Kho dữ liệu Infinispan mã nguồn mở phổ biến cho các hoạt động trong bộ nhớ. Ứng dụng .NET Core hiện có thể dễ dàng tích hợp Infinispan như một nhà cung cấp dịch vụ bộ nhớ đệm hoặc phiên. Bài viết này cung cấp thông tin cơ bản về cách thực hiện điều đó trong C # trên Linux .
Những gì bạn cần:
Trên máy chủ Infinispan, tạo bộ đệm ẩn có tên default
đang lắng nghe trên máy chủ loopback và cổng 127.0.0.1:11222 mà không cần xác thực.
Bạn sẽ làm việc trên ứng dụng ASP.NET Core , vì vậy hãy chạy lệnh sau để tạo khung ứng dụng mới:
dotnet new webapp -lang 'C#' -n Infinispan.Example.Caching -f net6.0
Lệnh này tạo một thư mục mới với ứng dụng ASP.NET Core trống nhưng đang hoạt động. Chạy ứng dụng như sau:
cd Infinispan.Example.Caching
dotnet run
Kiểm tra thông báo nhật ký của ứng dụng để tìm URL HTTP hoặc HTTPS của nó và nhập nó vào trình duyệt của bạn để xem màn hình của ứng dụng.
Ứng dụng yêu cầu gói bộ nhớ đệm Infinispan, vì vậy hãy thêm gói này như sau:
dotnet add package Infinispan.Hotrod.Caching --version 0.0.1-alpha3
Gói này cung cấp triển khai IDistibutedCache dựa trên ứng dụng khách Infinispan C #, được nhập dưới dạng phụ thuộc.
Ứng dụng ASP.NET Core (6.0) cung cấp tất cả các dịch vụ và thiết lập đường dẫn trong Program.cs
tệp. Đối với tệp này, bạn cần thêm cấu hình máy khách Infinispan trong thiết lập dịch vụ, cũng như quản lý phiên trong đường dẫn quy trình. Đặt các mục nhập trong bộ nhớ cache hết hạn sau 10 giây thời gian nhàn rỗi. Program.cs
bây giờ sẽ trông như thế này:
using Infinispan.Hotrod.Core;
using Infinispan.Hotrod.Caching.Distributed;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Infinispan default setup is used:
// 127.0.0.1:11222 cacheName: default
builder.Services.AddInfinispanCache();
builder.Services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromSeconds(10);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
});
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseSession();
app.MapRazorPages();
app.Run();
Mã doanh nghiệp của chúng tôi rất đơn giản: Nó trình bày một số thông tin (tên người dùng, độ tuổi của phiên và thời gian truy cập đầu tiên) cho người dùng do một yêu cầu. Dữ liệu được tìm nạp từ bộ đệm phiên nếu có sẵn ở đó và được chương trình tính toán theo cách khác. Logic này được thực hiện trong tệp mô hình Pages/Index.cshtml.cs
:
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Infinispan.Example.Caching.Pages
{
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
public IndexModel(ILogger<IndexModel> logger)
{
_logger = logger;
}
public const string SessionKeyName = "_Name";
public const string SessionKeyAge = "_Age";
public const string SessionKeyFirstAccess = "_FirstAccess";
public static Random RndSource = new Random();
public string DataSource { get; private set; } = "";
public void OnGet()
{
// Requires: using Microsoft.AspNetCore.Http;
if (string.IsNullOrEmpty(HttpContext.Session.GetString(SessionKeyName)))
{
DataSource = "Computed";
HttpContext.Session.SetString(SessionKeyName, "Mickey");
HttpContext.Session.SetInt32(SessionKeyAge, RndSource.Next(100));
HttpContext.Session.SetString(SessionKeyFirstAccess, DateTime.Now.ToString());
return;
}
DataSource = "Cache";
}
}
}
Đầu ra được tạo từ một tệp có tên Pages/Index.cshtml
:
@page
@using Infinispan.Example.Caching.Pages
@using Microsoft.AspNetCore.Http
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<h2>The time on the server is @DateTime.Now</h2>
<h2>Name (@Model.DataSource): @HttpContext.Session.GetString(IndexModel.SessionKeyName)</h2>
<h2>Age (@Model.DataSource): @HttpContext.Session.GetInt32(IndexModel.SessionKeyAge)</h2>
<h2>First Access Date (@Model.DataSource): @HttpContext.Session.GetString(IndexModel.SessionKeyFirstAccess)</h2>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
Mọi thứ đã sẵn sàng cho buổi biểu diễn. Chạy lại ứng dụng của bạn và kiểm tra kết quả đầu ra trong trình duyệt. Trường Age
và First Access Date
trường được tính toán lần đầu tiên và được lưu vào bộ nhớ cache trong 10 giây. Bản thân phiên sẽ hết hạn sau 10 giây thời gian nhàn rỗi, như được định cấu hình trong cấu hình dịch vụ. Do đó, các giá trị được lưu trong bộ nhớ cache sẽ được ứng dụng sử dụng lại nếu các yêu cầu liên tiếp xảy ra nhanh chóng.
Bài viết này đã trình bày cách bạn có thể tích hợp Infinispan dễ dàng như một trình cung cấp phiên và bộ đệm phân tán cho các ứng dụng ASP.Net Core.
#dotnet # aps.net #csharp
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
1596104770
Looking to outsource your asp dot net development requirement?
ASP.Net is a special feature of the DOT Net framework created by Microsoft. At HourlyDeveloper.io, we have a team of experienced ASP.Net developers who are experts in delivering custom solutions based on your business requirements. Hire ASP.Net Developers who will provide tailored solutions to facilitate your business growth.
Consult with experts: https://bit.ly/3fNpVqr
#hire asp.net developers #asp.net development company #asp.net development services #asp.net development #asp.net developer #asp.net
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
1622461866
A versatile Web & Mobile App Development framework technology that is fast, reliable, and easy to use is ASP.NET. ASP.NET gives the developer complete control over development and can be used on any project big or small.
Want to develop a website or mobile app with ASP.NET?
WebClues Infotech with years of experience and a highly skilled development team can be your go-to agency for your Web & Mobile App Development requirements. With an expert developer team of more than 150+ members, WebClues Infotech has successfully delivered more than 1500 projects worldwide.
Want to know more about the ASP.NET framework?
Visit: https://www.webcluesinfotech.com/asp-net-web-development/
Share your requirements https://www.webcluesinfotech.com/contact-us/
View Portfolio https://www.webcluesinfotech.com/portfolio/
#asp.net web development company #asp.net web development company usa #asp.net development company in india #asp.net development company #.net software development company #hire asp.net developer
1617882168
A universally accepted and the most popular framework that can be used for a small or big websites or Web application development projects is the ASP.NET. This framework is majorly used to produce an interactive and data driven web applications.
Are you looking to use an ASP.NET framework for your development needs?
WebClues Infotech offers a dedicated ASP.NET developers where a business can hire a dedicated ASP.NET developer that matches their project requirement. WebClues Infotech also has a flexible pricing structure that suits most project or business requirements.
Want to hire a dedicated ASP.NET developers?
Share your requirements here https://www.webcluesinfotech.com/contact-us/
Book Free Interview with ASP.NET developer: https://bit.ly/3dDShFg
#hire dedicated asp.net developers #hire asp.net developers #hire .net developers #full-stack .net developers india #dedicated .net programmers india #hire asp.net developers or programmers