TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed elbarbary
NA
1.6k
275.3k
How to use middle war to get next request asp.net core 2
Sep 15 2019 2:51 PM
How to get next request pipline in case of token success .
suppose i need to get data from action result get request by post man
[HttpGet(Contracts.ApiRoutes.Security.GetUserMenus)]
public
IActionResult GetUserMenu(
string
userId)
{
string
strUserMenus = _SecurityService.GetUserMenus(userId);
return
Ok(strUserMenus);
}
i write on postman link as then select get then write on header
key : authorization
value :eeerrttyyyyy
when invalid access token then it will show message invalid token
if valid access token it will continue execution and get result from action
this is actually i need on next but cannot do it
public
async Task InvokeAsync(HttpContext context, DataContext dataContext) {
var validKey =
false
;
// than you logic to validate token
var CheckExistAccessToken = context.Request.Headers.ContainsKey(
"Authorization"
);
var AccessTokenValue = context.Request.Headers[
"Authorization"
].SingleOrDefault();
if
(CheckExistAccessToken) {
bool
isvalid = _tockenvalidator.ValidateToken(AccessTokenValue);
if
(isvalid) {
validKey =
true
;
}
else
{
validKey =
false
;
}
}
if
(!validKey) {
context.Response.StatusCode = (
int
) HttpStatusCode.Forbidden;
await context.Response.WriteAsync(
"Invalid Token"
);
}
//if validm than next middleware Invoke
else
{
//success token
context.Request.EnableRewind();
await _next.Invoke(context);
// how to get next request meaning i need to get result of action getusermenu
}
}
}
my result show on post man as below but on my app show invalid token although
on i make debug and token is valid and reach until
await _next.Invoke(context); but not show result
actually i need to show data display on postman
Reply
Answers (
0
)
PushBullet notification to more than one person
get this error when i open doc file in browser