c# - Using Response.Write and Response.Redirect at the same time -


below asp.net mvc code,

        public void index()         {             response.write("hey");             response.redirect("https://www.google.com");         }   or   public void index()         {             response.redirect("https://www.google.com");             response.write("hey");         } 

here, redirecting working not write(). why redirect being given preference? mean why 302 , why not 200 in http response.

note: not addressing real time scenario. have curiosity know reason or underlying behavior.

respose.write working when execute redirect server sends response headers:

http/1.1 302 object moved

server: microsoft-iis/5.0

location: somewhere/newlocation.aspx

the browser initiates request (assuming supports redirects) somewhere/newlocation.aspx loading contents in browser.

anyway, if response stream buffered ("hey") overwriting response response.redirect.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -