Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpRequestException.StatusCode 错误 #242

Open
idea-zone opened this issue Jan 19, 2024 · 3 comments
Open

HttpRequestException.StatusCode 错误 #242

idea-zone opened this issue Jan 19, 2024 · 3 comments

Comments

@idea-zone
Copy link

版本: WebApiClinetCore 2.0.4

服务器相应错误的状态 403 报错时,拦截时对应 HttpRequestException.StatusCode 不是预期的 HttpStatusCode.Forbidden 值。
image

@EzrealJ
Copy link
Collaborator

EzrealJ commented Jan 20, 2024

此时HttpRequestException的InnerException是ApiResponseStatusException ,你可以在这里获取到403

((WebApiClientCore.Exceptions.ApiResponseStatusException)httpE.InnerException).StatusCode==HttpStatusCode.Forbidden

@EzrealJ
Copy link
Collaborator

EzrealJ commented Jan 20, 2024

https://learn.microsoft.com/zh-cn/dotnet/api/system.net.http.httprequestexception.statuscode
参考文档,此属性在.NET5首次添加,但WebApiClientCore仅面向netstandard2.1打包,因此没有对其进行赋值。

@EzrealJ EzrealJ added the 设计如此(as designed) 这个标签意味着设计的本意就是这样,将不会采纳修改意见(This label means that the design is intended to be like this, and no rev) label Jan 20, 2024
@xljiulang
Copy link
Collaborator

现已增加.net5的适配
9ae2aed

@EzrealJ EzrealJ removed the 设计如此(as designed) 这个标签意味着设计的本意就是这样,将不会采纳修改意见(This label means that the design is intended to be like this, and no rev) label Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants