当前位置:网站首页>ASP. NET CORE Study04
ASP. NET CORE Study04
2022-06-28 12:35:00 【When the human stars shine】
Binding source Attributes
With the help of binding source attributes You can pass the requested data to api, The details of the attribute Here's the picture .
but stay api Under the project of Marked apicontroller Of controller Next ,binding source attributes The rules of Something has changed 
HttpHEAD
head It is also a kind of http Request method , He followed get The method is very similar . The important difference is head Method does not return body , Only the response header information .
head It can be used to obtain some information on resources .
stay asp.net core Provides HTTP attribute HttpHead Use , Very convenient .
Filter and Search for
Filter : The first is a complete set , Then match them according to the conditions / Unmatched data items are removed .
Search for : The first is an empty set , Then match them according to the conditions / Add unmatched data items to it .
Pay attention to filtration Field of Only right Exposed to the outside world DTO Class .
asp.net core exception handling
Under development mode , Unexpected exception occurred in the program , Prompt information is returned to the user through exception handling , Instead of returning exception information directly , There are hidden dangers in security .
yes startup Class configure Method to configure .
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// Use useexceptionhandler Middle price to simply handle exceptions
app.UseExceptionHandler(appBuilder =>
{
appBuilder.Run(async context =>
{
context.Response.StatusCode = 500;
await context.Response.Body.WriteAsync(System.Text.Encoding.Default.GetBytes("Unexpected Error"));
});
});
}
http Security and idempotency

HTTP A detailed explanation of each method 
according to http The security and idempotency of methods , What methods can be used to provide references in various business scenarios .
Delivery complexity Action Parameters
When Action When more parameters are required , Pass directly through formal parameters , This leads to very redundant code , So you need to use Model class To accept complex parameters , Handle the transfer of complex parameters .
First of all, you need to declare Model class , Is the basic simple ordinary c# class
public class CompanyDtoParameters
{
public String CompanyName {
get; set; }
public String SearchTerm {
get; set; }
}
Note that the name of the attribute is the key name of the requested data .
And then in service Class and controller Use in


Be careful controller in You need to specify the Data source of model binding .
边栏推荐
- UGUI强制刷新Layout(布局)组件
- Jerry's wif interferes with Bluetooth [chapter]
- Privilege management of vivo mobile phone
- C语言 sprintf函数使用详解
- Is tongdaxin stock software reliable? Is it safe to trade stocks on it?
- 不到一小时,苹果摧毁了15家初创公司
- 设置Canvas的 overrideSorting不生效
- UDP RTP packet frame loss
- Is there a threshold for opening futures accounts? How to open futures accounts safely on the Internet
- Custom title bar view
猜你喜欢

Bytev builds a dynamic digital twin network security platform -- helping network security development

Function and principle of remoteviews

From simplekv to redis

ASP. NET CORE Study03

最新!基于Open3D的点云处理入门与实战教程

深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图...

我的NVIDIA开发者之旅-Jetson Nano 2gb教你怎么训练模型(完整的模型训练套路)

UGUI强制刷新Layout(布局)组件

不到一小时,苹果摧毁了15家初创公司

洛谷_P1303 A*B Problem_高精度计算
随机推荐
JNI函数的2种书写方式
[C language] use of file read / write function
最新!基于Open3D的点云处理入门与实战教程
UDP RTP packet frame loss
2022-06-28日报:LeCun最新论文:通往自主机器智能的道路
【Unity编辑器扩展基础】、EditorGUILayout (三)
Is tongdaxin stock software reliable? Is it safe to trade stocks on it?
真正的学懂三极管入门篇(经典)「建议收藏」
ASP.NET CORE Study09
杰理之wif 干扰蓝牙【篇】
JS duration and asynchronous function promise
Mr. Zhang responded to the first live broadcast with goods
《数字经济全景白皮书》消费金融数字化篇 重磅发布
结构光之相移法+多频外差的数学原理推导
AsyncTask经验小结
After importing resources, unity also manually modifies the properties of resources? This code can save you a lot of time: assetpostprocessor
Unity releases webgl and wakes up keyboard input on the mobile terminal inputfield
MATLAB的官方网站上其实有很多MATLAB的学习和使用资料(文档、视频都有不少)
Jerry's wif interferes with Bluetooth [chapter]
Levels – 虚幻引擎场景制作「建议收藏」