Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Articles by Using Microsoft. AspNetCore.Http
Use Dev Proxy with .NET Azure Functions
Share via Note Access to this page requires authorization. You can try signing in or changing directories. Access to this page requires authorization. You can try changing directories. At a glance Goal: Use Dev Proxy with .NET Azure Functions Time: 10 minutes Plugins: Various Prerequisites: Set up Dev Proxy, Azure Functions Core Tools If you build Azure Functions using .NET and want to use Dev Proxy, follow the general guidance for using Dev Proxy with .NET applications.
Introduction Visual Studio Code (VS Code) is a lightweight yet powerful code editor that supports C# development with ease. Whether you're building a simple console application or a basic web app, correctly setting up your development environment is essential. This guide will walk you through setting up VS Code to create a simple C# console app and a minimal web app (a number guessing game) using ASP.NET Core.
Building C# Web and Console Applications: A Hands-On Guide with a Guessing Game
Introduction C# is a versatile programming language widely used for developing various types of applications, including web and console applications. The .NET framework and .NET Core provide robust environments for building scalable, high-performance applications. This guide outlines the steps for creating a C# web application using ASP.NET Core and a C# console application using .NET. As part of this tutorial, we will build a simple Guessing Game for both console and web environments.
Develop Microservices Using Azure Functions, API Management
Microservices are a popular architectural pattern for building scalable and modular applications. They allow developers to focus on building small, independent, and reusable services that interact with each other through APIs. This blog will guide you through creating a simple serverless microservice and deploying it to Azure Cloud. I have used this approach to start building simple prototypes of various products, get early feedback from customers, and iterate faster.
How to Enhance the API Response with a Wrapper Class with Additional Information with .NET Minimal API
One of the challenges of using API (minimal or not) is how to customize the response format and include additional information such as metadata, pagination, error messages, etc. In this article, we will explore how to use a wrapper class to achieve this goal. What is a Wrapper Class? A wrapper class is a class that wraps another object or value and provides some additional functionality or properties.
如何在 ASP.NET Core 中实现速率限制?
在 ASP.NET Core 中实现速率限制(Rate Limiting)中间件可以帮助你控制客户端对 API 的请求频率,防止滥用和过载。速率限制通常用于保护服务器资源,确保服务的稳定性和可用性。 ASP.NET Core 本身并没有内置的速率限制中间件,但你可以通过自定义中间件或使用第三方库来实现速率限制。以下是实现速率限制的几种常见方法: 你可以通过自定义中间件来实现速率限制。以下是一个简单的实现示例: 1.1 实现速率限制中间件 using Microsoft.AspNetCore.Http; using System.Collections.Concurrent; using System.Threading.Tasks; public class RateLimitingMiddleware { private readonly RequestDelegate _next; private readonly int _maxRequests; // 每分钟允许的最大请求数 private readonly ConcurrentDictionary<string,...
Uploading Files to Amazon S3 in ASP.NET Core with Razor Pages
In this post we are going to explore how to upload file to our AWS S3 repository from an ASP.NET Core with Razor Pages app. In this case we make use of Visual studio for the creation and configuration of the solution: We select and create the Asp.Net project type. Created the solution we install the package nuget AWSSDK.S3 from the AwsS3 library For this solution we are going to implement the repository pattern and start creating the interface for the file upload.
Exception Handling in C#
Table of Contents Types of Exceptions Using try-catch-finally How to Avoid Exceptions 4.1 Input Validation 5.2 Custom Middleware 6.4 Handling Results 8.1 Use Descriptive Names 1. What Is an Exception in C#? In C#, an exception is an unexpected event that occurs when an operation cannot be executed as intended. Exceptions allow you to handle runtime errors gracefully and define specific actions to prevent your program from crashing abruptly.
Azure Functions in .NET (C#) - The Ultimate Fun Version 🥳
What is Azure Functions? Imagine you’re throwing a party. You have tons of guests (events) arriving at different times. Instead of hiring a full-time butler (server) to manage it all, you have Azure Functions, which is like a party planner who only shows up when needed. When a guest arrives (an event happens), the planner (your function) gets to work, does their thing, and leaves when the job is done. No hassle, no drama. Just pure serverless fun! 🥳 Why Should You Care About Azure Functions?
Part 2 - Multichannel notification system using Azure Communication Services and Azure Functions
In the first part of this topic, we setup all the Azure resources like the Azure Communication Services for Email, SMS, WhatsApp for Business and developed the Azure Functions code for the email trigger.
The Dotnet, Nx, AnalogJs (Angular) Stack is here - Part 1
𧬠What is the DNA Stack? Introduction: First of all, let me give credit to Brandon Roberts for coming up with the name π₯Έ. The DNA stack represents a powerful combination of technologies: .NET Core, NX tools, and AnalogJS, providing developers with a cohesive and efficient environment to build robust applications. Let's briefly dive into each of these technologies without too much explanation, since they all have excellent documentation.
使用 Syncfusion .Net PDF Fram 创建 PDF 的 Azure 函数应用程序
我们有几个用例需要内部和外部用户以 PDF 格式打印内容。我们已将此功能从 DXP Web App 卸载到在 Docker 容器中运行的 Azure Function App。我们使用 Syncfusion .Net PDF Framework(注意:需要订阅)。我们的第一个用例允许您提供用于打印的端点 URL。第二个用例涉及将 XHTML 内容数组发布到端点。 创建 Azure 函数应用 在 Visual Studio 中创建一个新项目并选择 Azure Functions。 为项目命名 我这里采用默认设置: .Net 8 隔离 对于版本 Http 触发器 对于该函数,因为我们将使用 GET 和 POST 启用容器支持 因为我们将使用 Docker 功能 授权级别,因此需要功能密钥。(当在此授权级别托管在 Azure 中时,需要功能密钥才能访问端点。) 单击“创建”。 这为我们提供了基本的支架。 using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using...
Azure | Azure Functions By Example
Note You can check other posts on my personal website: https://hbolajraf.net Microsoft Azure Functions Example In this example, we'll create a simple Azure Functions application in C#. Azure Functions is a serverless compute service that allows you to run event-triggered code without managing infrastructure. We will create a function that responds to an HTTP request. Prerequisites Before you begin, make sure you have the following prerequisites: Microsoft Azure account.
An Introduction to ASP.NET Core MVC through an Example (Part 5)
Introduction In Part 4, we added basic support for the shopping cart, and now we'll enhance and refine that functionality. In this article, we are going to use the services feature that sits at the heart of ASP.NET Core to simplify the way that Cart objects are managed, freeing individual components from needing to deal with the details directly. Background This article is a continuation of the previous 4 articles.
Asp.NET Core WebAPI 入门学习笔记,超详细
1.WebAPI概述 WebAPI 是一种传统的方式,用于构建和暴露 RESTUI风格的Web服务。它提供了丰富的功能和灵活性,可以处理各种HTTP请求,并支持各种数据格式,如JSON、XML等。 WebAPI使用控制器(Controllers)和动作方法(ActionMethods)的概念、通过路由配置将请求映射到相应的方法上。 开发人员可以使用各种属性和过滤器来处理请求、控制访问权限、验证数据等。 MinimaIAPI 是ASP.NET COre6引入的一种新的轻量级 API开发模型。 它旨在简化 API的创建过程,提供更简洁、更集中的代码结构。 MinimalAP1基于函数式编程模型,通过一个顶级的webAppiication 类来配置路由和请求处理。开发人员可以使用链式调用的方式定义路由、请求处理逻辑和中间件。这种模型更加直观和易于理解,尤其适合构建小型的、单一用途的 WebAPI。 与WebAPI相比,MinimalAPI的主要区别包括: 1.代码量更少:MinimalAPI基于函数式编程模型,代码更加简洁、消除了控制器和动作方法的概念。...
【入门】.Net Core 6 WebApi 项目搭建
1.1.创建新项目:打开开发工具>创建新项目>搜索API>选择C#语言的ASP.NET Core Web API 1.2.配置新项目:**自定义项目信息以及存储路径 1.3.其他信息:这里框架必须选择.NET 6.0,其他配置默认勾选即可,也可以根据自己的需求进行更改 1.4.创建完成之后就得到了一个最基础的Core6项目框架代码 Program.cs就是该项目程序的配置,在Core6中Program.cs 集成了 Startup.cs 的配置 项目结构分析,.net6中删除了startup.cs,整合到了Program.cs 创建Controller 可以先将系统默认创建的WeatherForecastController.cs和WeatherForecast.cs进行删除,然后在controller文件夹新建一个控制器,命名:UserController.cs 在UserController中增加一个Hello的get方式的接口方法,返回"你好世界",通过请求api/user/hello来获取该接口的结果 using Microsoft.AspNetCore.Http;...
使用asp.net core web api创建web后台,并连接和使用Sql Server数据库
前言:因为要写一个安卓端app,实现从服务器中获取电影数据,所以需要搭建服务端代码,之前学过C#,所以想用C#实现服务器段代码用于测试,本文使用C#语言,使用asp.net core web api组件搭建服务器端,并访问sql server 数据库。 二、 创建ASP.NET Core Web API,选择C#语言。 如下图所示 后面一路默认配置即可,创建后会有个实例代码,个人感觉挺有意义,对于初次使用的人很有参考价值。因为程序中用到图片转base64格式字符串和使用sqlserver数据库,需要下载NuGet程序包,下载方法,解决方案--右键--“管理解决方案的NuGet程序包”,下载如下缺少的包,如下图: 2.安装Nuet程序包——项目——依赖项——管理NuGet程序包(版本等级尽量一样) Microsoft.EntityFrameworkCore Microsoft.EntityFrameworkCore.SqlServer (适用于EF Core SQL Server 提供程序) Microsoft.EntityFrameworkCore.Tools(适用于 EF...
Building a .NET 7 Microservice with Monitoring and Centralized Logging on Gitpod
Microservices have become an integral part of modern application architecture, allowing teams to build scalable, maintainable, and independently deployable modules. With the rise of distributed systems, monitoring and centralized logging have become crucial components to ensure the system's health and track issues. In this tutorial, we'll walk through creating a .NET microservice using the latest .NET 7 framework on Gitpod, a cloud-based development environment.
详解ASP.NET Core实现的文件断点上传下载
2023-09-06 08:33:30 在 ASP.NET Core 应用程序中,创建一个名为 UploadController 的控制器。在该控制器中,使用 ApiControllerAttribute 特性声明该控制器为 Web API 控制器。 场景分析 文件的断点续传功能可以应用于需要上传或下载大文件的场景。在网络状况不佳或者文件较大时,一次性上传或下载整个文件可能会耗费大量时间和带宽,并且可能会导致因中断而失败的情况发生。通过实现文件的断点续传功能,可以将大文件分割成小块,分别上传或下载,即使在网络出现问题时也可以通过上传或下载已经完成的文件块来继续未完成的操作,减少耗时和带宽消耗,提高用户体验。常见的应用场景如:视频、音频文件的上传或下载,大型软件的更新或下载,云盘等文件存储服务等等。 设计思路 在asp.net core 中实现文件的断点续传功能,需要进行以下步骤: 客户端与服务端建立连接。 客户端上传文件时,将文件切割成小块并分别传输到服务端。 服务端接收到文件块后进行校验和整合。 客户端下载文件时,请求服务端指定位置开始的文件块,并按照顺序拼接成完整文件。...
asp.net core之EfCore
EF Core(Entity Framework Core)是一个轻量级、跨平台的对象关系映射(ORM)框架,用于在.NET应用程序中访问和操作数据库。它是Entity Framework的下一代版本,专为.NET Core应用程序而设计。 EF Core提供了一种简单、灵活和高效的方式来与各种数据库进行交互,它通过将数据库表映射为.NET对象,并提供了一组强大的查询语言和操作API,使开发人员能够以面向对象的方式进行数据库操作。 本文是一个简单的EF Core教程,演示了如何使用EF Core进行数据库操作。 1. 安装EF Core 首先,创建一个WebApi项目,我们需要安装EF Core。可以通过NuGet包管理器或使用dotnet命令行工具来安装EF Core。 dotnet add package Microsoft.EntityFrameworkCore 2.
EF Core + MySQL 基本增删改查
基于EF Core + MySQL的基本增删改查,示例是基于.NET6 + EF Core + MySQL 创建实体和数据库、EFCore 数据迁移项目基础上的内容增加。同时也是对基于Canal实现MySQL 8.0 数据库数据同步项目的验证。 Controllers---->添加---->控制器,选择api---->包含读写操作的API控制器。 将上下文类注入到UsersController中,ASP.NET Core 支持依赖关系注入 (DI) 软件设计模式,这是一种在类及其依赖关系之间实现控制反转 (IoC) 的技术。有三种具体实现方式,我们这里用到的是构造函数注入,关于这块的内容,以后我们也可以专门出一期。直接上代码。 private readonly MyDataBaseContext_mian _dbmain; private readonly MyDataBaseContext_from _dbfrom; public UsersController(MyDataBaseContext_mian dbmain, MyDataBaseContext_from...
aspnetcore最最简单的接口权限认证 - 星仔007 - 博客园
五月一眨眼就过去,就当凑个数吧。 场景: 一个小小的项目,需要一个后台,就展示几个列表,连用户表、角色表等都不需要设计。 之前有写过identityserver4和jwt4的demo (exercisebook/IdentityServer4&Serilog at main · liuzhixin405/exercisebook · GitHub exercisebook/授权/授权一/JwtToken at main · liuzhixin405/exercisebook · GitHub), 但是这样一个项目中上这些肯定是大材小用。 微软提供的还有一个就是cookie,既然够简单,那么什么也不用设计,尽量做到最简单,而且后期还可以通过表设计来完善这个的后台登录模块。 首先我们要实现的就是接口代码的授权: [Authorize] [ApiController] [Route("[controller]")] public class WeatherForecastController : ControllerBase { private static readonly...
.NET 6 实现敏感词过滤
你的位置:首页 > 软件开发 > ASP.net > .NET 6 实现敏感词过滤 发布时间:2023-03-27 10:47:04 一、什么是敏感词过滤? 敏感词过滤是一种处理网络内容的技术,可以检测和过滤出网络中的敏感/违禁词汇。它通过给定的关键字或字符串,判断网络内容是否包含某些敏感信息,从而防止违反法律法规的信息流通。 通常 一、什么是敏感词过滤? 敏感词过滤是一种处理网络内容的技术,可以检测和过滤出网络中的敏感/违禁词汇。它通过给定的关键字或字符串,判断网络内容是否包含某些敏感信息,从而防止违反法律法规的信息流通。 通常,可以使用两种方法来过滤敏感词: 黑名单过滤:即定义一个黑名单,将所有敏感词择记录在其中,然后对输入的文本进行对比,如果发现有敏感词,就将其过滤掉。 白名单过滤:即定义一个白名单,将所有不敏感的词汇记录在其中,然后对输入的文本进行对比,如果发现有不在白名单中的词汇,就将其过滤掉。 二、ToolGood.Words是什么?...
Net DB Web多级缓存的实现
1、客户端缓存(浏览器缓存) HTTP有一套控制缓存的协议-RFC7234,其中最重要的就是cache-control这个相应报文头,服务器返回时,如果Response带上 cache-control:max-age=5 #表示允许浏览器缓存5秒(仅是允许,浏览器是否缓存还看浏览器本身机制是否要遵循这套缓存协议) Net 封装好了一个缓存特性,如: public class HomeController : ControllerBase { [ResponseCache(Duration = 5)]//告诉浏览器可用缓存5秒,Duration必须定义,不然请求会报错 [HttpGet("GetNowDateTime")] public string GetNowDateTime() { return DateTime.Now.ToString(); } } 执行多次请求 第一行为首次请求,Response Headers: cache-control: public,max-age=5 #告诉浏览器进行缓存 content-encoding: gzip content-type:...
Deaktivieren Sie Sticky Sessions in Optimizely DXP
Dieser ist für alle Website-Entwickler, die mit Multi-Server-Load-Balancing-Sites arbeiten. Routing-Affinität, mit Namen wie ARR-Affinität (auf Azure App Service und IIS), Klebrige Sitzung (in Nginx, Apache mod_proxy usw.) und ähnliche sind Lastausgleichstechniken. Sie alle stellen sicher, dass Anfragen aus einer einzelnen Browsersitzung ausschließlich von demselben Ursprungsserver bedient werden.
I Used GPT-3 to Find 213 Security Vulnerabilities in a Single Codebase
Meanwhile, one of the best tools on the market only found 99 Summary: GPT-3 found 213 security vulnerabilities in this git repository. In comparison, one of the better commercial tools on the market (from a reputable cybersecurity company) only found 99 issues, although their tool provides context in a more structured format. After manually reviewing a random sample of 50 / 213 of the vulnerabilities detected by GPT-3, only one was a false positive. Both tools had many false negatives.
【ASP.NET Core】用配置文件来设置授权角色
在开始之前,老周先祝各个次元的伙伴们新春快乐、生活愉快、万事如意。 在上一篇水文中,老周介绍了角色授权的一些内容。本篇咱们来聊一个比较实际的问题——把用于授权的角色名称放到外部配置,不要硬编码,以方便后期修改。 由于要配置的东西比较简单,咱们并不需要存在数据库,而是用 JSON 文件配置就可以了。将授权策略和角色列表关联起来。比如,老周这里有个 authorRoles.json 文件,它的内容如下: { "cust1": { "roles": ["admin", "supperuser"] }, "cust2": { "roles": ["user", "web", "logger"] } } 其中,cust1、cust2 是策略名称,所以上面就配置了两个授权策略。每个策略下有个 roles 属性,它的值是数组,这个数组用来指定此策略下允许的角色列表。故:cust1 策略下允许admin、supperuser两种角色的用户访问;cust2 策略下允许 user、web、logger 角色的用户访问。 在 WebApplicationBuilder 的配置中,咱们可以单独加载...
Application Insights logging with .NET - Azure Monitor
Read in English Read in English Edit Twitter LinkedIn Facebook Email Article 12/28/2022 10 minutes to read In this article In this article, you'll learn how to capture logs with Application Insights in .NET apps by using several NuGet packages: Core package: Microsoft.Extensions.Logging.ApplicationInsights Workload packages: Microsoft.ApplicationInsights.AspNetCore Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel Tip The Microsoft.ApplicationInsights.WorkerService NuGet package,...
猿创征文|【国产数据库】一文学会应用SqlSugar工作单元模式操作多数据库_会敲键盘的肘子的博客-CSDN博客
随着华为、中兴事务,国产数据库市场相信是未来是趋势走向,纵观 .net core 整个圈子FreeSql和SqlSugar(排名不分先后)都已早早支持国产数据库,比如人大金仓、神通、达梦,针对不同的项目要求支持适配不同的国产数据库。今天我们使用 SqlSugar ORM 的工作单元模式来连接多个国产数据库。 SqlSugar是一款来自未来的ORM,开箱即用,拥有超前的理念,需求领跑第一线,在设计理念上就算不更新几年都不会过时,是一款真正用了功能齐全的ORM框架。 👉本文关键字:国产数据库、SqlSugar、ORM、人大金仓、达梦、翰高 ♈ 基本介绍 SqlSugar 是一款 老牌 .NET 开源ORM框架,由果糖大数据科技团队维护和更新 ,开箱即用最易上手的ORM框架 ,51Job和Boss直招简历数超过 国外框架 Nhibernate PetaPoco, 仅次于Dapper和EF Core , 占Dapper 40% 。 ⭐ 功能介绍 相比EF Core【学习成本低一天学会】,多库支持更好 ,在国内拥有不逊色EF Core 的【开源生态】。 支持 .NET...
Rethinking the Web - Part 1
What would the web look like if the pioneers had the tools and tech we have today? What would the OO software look like if we used the OO paradigm championed by the developers of the web? Why has software development become so complicated? This series of articles answers these questions, and presents an alternate approach to how we design and develop software. Preface In the mid 1990's software development was reasonably predictable.
.NET WebAPI 运用JWT鉴权授权
1:引用需要的程序集 :System.IdentityModel.Token.JWT 2:创建一个新的控制器,用于授权功能 using Demo.APIDbcontext; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Cors; using Microsoft.IdentityModel.Tokens; using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; using System.Text; namespace Demo.Controllers { [Route("api/[controller]/[Action]")] [ApiController] public class JWT : ControllerBase { private readonly...
Request Response Logging Middleware ASP.NET Core
Download LogMiddleware.zip - 9.7 KB Background A middleware is a component class that is executed on every request in the ASP.NET application. There could be multiple middleware in the ASP.NET web application. It can be either framework provided or added via NuGet or your own custom middleware. This example uses middleware to log each request response and other information. Here we will focus on, how to generate and store logs using middleware.
.Net Core WebApi 系列:过滤器Filter
过滤器有什么作用,在什么场景下适合用到它? 假设一个项目进展到快结束的时候,项目leader为了保证程序的稳定性和可监控和维护性要求将所有的方法加上日志,如果项目比较庞大,方法非常多,那岂不是得费很大得劲来完成这样一件事情。不过不用担心,咋们遇到的问题,伟大的语言设计者早已帮我们想好了解决办法过滤器,过滤器是一种AOP(面向切面编程)技术的体现,AOP具有松耦合,易扩展,代码可复用的特点。 通常我们在这些场景下如身份验证、日志记录、异常获取等会使用到过滤器 .NET Core中的过滤器生命周期: .NET Core中的过滤器有多种,先介绍ActionFilterAttribute的用法 (1)自定义一个Filter类: using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using System; using System.Collections.Generic; using System.Linq; using...
Client to Server File/Data Streaming
Trying to find an authoritative reference guide for how to stream upload client files to a server was an arduous task, hence this article. Download FileStreaming.zip - 823.4 KB Contents Trying to find an authoritative reference guide for how to stream upload client files to a server was an arduous task, hence this article.
Adding authentication to a Blazor Server app using Auth0
In this post I show how how to add authentication to a sample ASP.NET Core Blazor Server app. The default .NET templates show how to use ASP.NET Identity or Azure for authentication, but in this post I show how to use Auth0 for authentication. Authentication in Blazor Server Blazor server is a stateful service. In normal operation, the Blazor server application running on the server maintains a SignalR connection to the user's browser, and sends diff updates to the browser.
Using Ajax and REST APIs in.NET 5
Asynchronous JavaScript and XML (Ajax) is the cornerstone of communication between client-side and server-side code. Regardless of whether you use JavaScript, jQuery, Angular, React, or any other client-side language, they all use Ajax under the hood to send and receive data from a Web server. Using Ajax, you can read data from, or send data to, a Web server all without reloading the current Web page.
Show More
loading
Actions
Is this you?
As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.Get in touch with Using Microsoft.
Contact Using Microsoft., search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack