Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
problem

why result not changed on browser invoke method custom middle ware after loaded for first time ?

1 - I put breakpoints on invoke method on custom middle ware and run visual studio on run time first time .

2 - after load it hit function invoke then it check variable AccessTokenValue it will be null so that it print on browser invalid value .
until here not have any problem .


3 - after that i open post man program and run it .
and put URL as get request then add on header
key :Authorization
Value:1234


4 - after that press send button from post man it hit breakpoints of invoke method and check variable AccessTokenValue and check his value it become 1234 so that it return on post man
valid value but on my browser value still invalid value .

Are this normal and why browser not refresh to update status based on condition statement on invoke method why his value still after load fixed or this futures of middle ware
Can any one help me ?
I work on visual studio 2017 asp.net core 2.2 i do following steps as following

What I have tried:

C#
public async Task InvokeAsync(HttpContext context)
        {
            
                var AccessTokenValue = context.Request.Headers["Authorization"].SingleOrDefault();
            if (AccessTokenValue == "1234")
            {
                context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
                await context.Response.WriteAsync("valid value");
                
            }
           
            else
                {
                context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
                await context.Response.WriteAsync("Invalid value");
               

            }
            
            
        }
    }
Posted
Updated 17-Sep-19 6:39am

1 solution

Requests made through Postman have absolutely no connection to requests made through your browser.

Just like requests made through your browser have absolutely no connection to requests made through my browser.

Why would you expect the header sent by one application to also be sent by a completely different application?
 
Share this answer
 
Comments
ahmed_sa 17-Sep-19 21:33pm    
thank you for reply this mean that I have problem on my app or this not problem
ahmed_sa 17-Sep-19 21:38pm    
can you give me more details about your answer please
Richard Deeming 18-Sep-19 6:34am    
A request sent from one program will not alter a request sent from a different program, even if those programs are on the same computer.

What more information do you need?
ahmed_sa 19-Sep-19 10:16am    
what i meed to ask why data reponse not show when call next on custom middleware
ahmed_sa 19-Sep-19 10:21am    
from debug i check my code if if (AccessTokenValue == "1234") is true it must print on browser valid value but it not make that it print invalid value
why that happen
from post man it give me valid value as correct result to my code
can you please help me really it strange problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900