Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
67e8f4e3
Commit
67e8f4e3
authored
May 28, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
dd784a71
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
22 deletions
+28
-22
ApiFilterAttribute.cs
Mall.WebApi/Filter/ApiFilterAttribute.cs
+21
-22
Program.cs
Mall.WebApi/Program.cs
+7
-0
No files found.
Mall.WebApi/Filter/ApiFilterAttribute.cs
View file @
67e8f4e3
...
@@ -138,34 +138,33 @@ namespace Mall.WebApi.Filter
...
@@ -138,34 +138,33 @@ namespace Mall.WebApi.Filter
/// <returns></returns>
/// <returns></returns>
private
JObject
DoApiMonitorLog
(
ActionExecutingContext
actionContext
,
ref
string
token
)
private
JObject
DoApiMonitorLog
(
ActionExecutingContext
actionContext
,
ref
string
token
)
{
{
JObject
parm
=
new
JObject
();
JObject
parm
=
new
JObject
();
var
request
=
actionContext
.
HttpContext
.
Request
;
var
request
=
actionContext
.
HttpContext
.
Request
;
#
region
如果参数是
json
实体对象,获取序列化后的数据
#
region
如果参数是
json
实体对象,获取序列化后的数据
request
.
EnableBuffering
();
//重置读取
request
.
EnableBuffering
();
request
.
Body
.
Seek
(
0
,
SeekOrigin
.
Begin
);
string
responseData
=
""
;
request
.
Body
.
Position
=
0
;
using
(
var
reader
=
new
StreamReader
(
request
.
Body
,
encoding
:
Encoding
.
UTF8
))
Stream
stream
=
request
.
Body
;
{
Encoding
encoding
=
Encoding
.
UTF8
;
var
body
=
reader
.
ReadToEndAsync
();
if
(
request
.
ContentLength
>
0
)
// Do some processing with body…
// Reset the request body stream position so the next middleware can read it
responseData
=
body
.
Result
;
request
.
Body
.
Position
=
0
;
}
if
(!
string
.
IsNullOrWhiteSpace
(
responseData
.
Trim
()))
{
{
byte
[]
buffer
=
new
byte
[
request
.
ContentLength
.
Value
];
try
stream
.
Read
(
buffer
,
0
,
buffer
.
Length
);
string
responseData
=
Encoding
.
UTF8
.
GetString
(
buffer
);
if
(!
string
.
IsNullOrWhiteSpace
(
responseData
.
Trim
()))
{
{
try
parm
=
JObject
.
Parse
(
responseData
);
{
actionContext
.
HttpContext
.
Items
[
GlobalKey
.
UserPostInfo
]
=
responseData
;
parm
=
JObject
.
Parse
(
responseData
);
}
actionContext
.
HttpContext
.
Items
[
GlobalKey
.
UserPostInfo
]
=
responseData
;
catch
(
Exception
ex
)
}
{
catch
(
Exception
ex
)
LogHelper
.
Write
(
ex
,
string
.
Format
(
"DoApiMonitorLog:{0}"
,
responseData
));
{
LogHelper
.
Write
(
ex
,
string
.
Format
(
"DoApiMonitorLog:{0}"
,
responseData
));
}
token
=
JsonHelper
.
GetStringValue
(
parm
,
"token"
);
}
}
token
=
JsonHelper
.
GetStringValue
(
parm
,
"token"
);
}
}
#
endregion
#
endregion
return
parm
;
return
parm
;
}
}
...
...
Mall.WebApi/Program.cs
View file @
67e8f4e3
...
@@ -2,6 +2,7 @@ using System;
...
@@ -2,6 +2,7 @@ using System;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
...
@@ -20,6 +21,12 @@ namespace Mall.WebApi
...
@@ -20,6 +21,12 @@ namespace Mall.WebApi
Host
.
CreateDefaultBuilder
(
args
)
Host
.
CreateDefaultBuilder
(
args
)
.
ConfigureWebHostDefaults
(
webBuilder
=>
.
ConfigureWebHostDefaults
(
webBuilder
=>
{
{
webBuilder
.
ConfigureKestrel
((
context
,
options
)
=>
{
options
.
AllowSynchronousIO
=
true
;
//设置应用服务器Kestrel请求体最大为50MB
options
.
Limits
.
MaxRequestBodySize
=
52428800
;
});
webBuilder
.
UseStartup
<
Startup
>().
UseIIS
();
webBuilder
.
UseStartup
<
Startup
>().
UseIIS
();
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment