{"id":113,"date":"2016-03-19T11:34:41","date_gmt":"2016-03-19T10:34:41","guid":{"rendered":"https:\/\/solidt.eu\/blog\/?p=113"},"modified":"2016-03-19T11:39:29","modified_gmt":"2016-03-19T10:39:29","slug":"c-send-redirect-response","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/c-send-redirect-response\/","title":{"rendered":"C# Send redirect response"},"content":{"rendered":"<p>Redirect helper functions<\/p>\n<pre lang=\"c#\">\r\npublic static void Redirect(string url)\r\n{\r\n\tHttpContext.Current.Response.AddHeader(\"Cache-Control\", \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\");\r\n\tHttpContext.Current.Response.AddHeader(\"Pragma\", \"no-cache\");\r\n\tHttpContext.Current.Response.Redirect(url, false);\r\n\tHttpContext.Current.Response.StatusCode = 302;\r\n\tHttpContext.Current.ApplicationInstance.CompleteRequest();\r\n}\r\n\r\npublic static void RedirectContinue(string url)\r\n{\r\n\tHttpContext.Current.Response.AddHeader(\"Cache-Control\", \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\");\r\n\tHttpContext.Current.Response.AddHeader(\"Pragma\", \"no-cache\");\r\n\tHttpContext.Current.Response.StatusCode = 302;\r\n\tHttpContext.Current.Response.Redirect(url, false);\r\n}\r\n\r\npublic static void RedirectPermanent(string url)\r\n{\r\n\tHttpContext.Current.Response.Redirect(url, false);\r\n\tHttpContext.Current.Response.ExpiresAbsolute = DateTime.UtcNow.AddDays(1);\r\n\tHttpContext.Current.Response.StatusCode = 301;\r\n\tHttpContext.Current.ApplicationInstance.CompleteRequest();\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Redirect helper functions public static void Redirect(string url) { HttpContext.Current.Response.AddHeader(&#8220;Cache-Control&#8221;, &#8220;no-store, no-cache, must-revalidate, post-check=0, pre-check=0&#8221;); HttpContext.Current.Response.AddHeader(&#8220;Pragma&#8221;, &#8220;no-cache&#8221;); HttpContext.Current.Response.Redirect(url, false); HttpContext.Current.Response.StatusCode = 302; HttpContext.Current.ApplicationInstance.CompleteRequest(); } public static void RedirectContinue(string url) { HttpContext.Current.Response.AddHeader(&#8220;Cache-Control&#8221;, &#8220;no-store, no-cache, must-revalidate, post-check=0, pre-check=0&#8221;); HttpContext.Current.Response.AddHeader(&#8220;Pragma&#8221;, &#8220;no-cache&#8221;); HttpContext.Current.Response.StatusCode = 302; HttpContext.Current.Response.Redirect(url, false); } public static void RedirectPermanent(string url) { HttpContext.Current.Response.Redirect(url, false); HttpContext.Current.Response.ExpiresAbsolute = DateTime.UtcNow.AddDays(1); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-113","post","type-post","status-publish","format-standard","hentry","category-dotnet"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=113"}],"version-history":[{"count":1,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/113\/revisions"}],"predecessor-version":[{"id":114,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/113\/revisions\/114"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}