3 Replies - 342 Views - Last Post: 18 September 2019 - 05:59 PM Rate Topic: -----

#1 ahmedba   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 220
  • Joined: 24-January 14

Why result not changed on browser when custom middle ware loaded for f

Posted 16 September 2019 - 08:00 PM

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 headerValue 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 headerValue 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:


public async Task InvokeAsync(HttpContext context)
        {
            
                var headerValue = context.Request.Headers["Authorization"].SingleOrDefault();
            if (headerValue == "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");
               

            }
            
            
        }
    }


Is This A Good Question/Topic? 0
  • +

Replies To: Why result not changed on browser when custom middle ware loaded for f

#2 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7135
  • View blog
  • Posts: 24,237
  • Joined: 05-May 12

Re: Why result not changed on browser when custom middle ware loaded for f

Posted 17 September 2019 - 05:51 PM

Perhaps the browser is caching responses?

What happens if you turn on the F12 dev tools and check the "Disable cache" checkbox? Do you still get the same behavior?
Was This Post Helpful? 0
  • +
  • -

#3 ahmedba   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 220
  • Joined: 24-January 14

Re: Why result not changed on browser when custom middle ware loaded for f

Posted 17 September 2019 - 09:52 PM

this is not caching problem because i change browser give me same result
also
i change content message show to me same message i changed
i change message from invalid token to invalidaccesstoken it show as invalidaccesoken
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7135
  • View blog
  • Posts: 24,237
  • Joined: 05-May 12

Re: Why result not changed on browser when custom middle ware loaded for f

Posted 18 September 2019 - 05:59 PM

Since you knew how to debug your code while being called by Postman, why not simply debug while being called by the browser to see what is happening?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1