c# - How to set ActionExecutingContext status code -


i using localization actionfilterattribute , working fine, except need redirect / /en status code of 301 instead of 302. how can fix this?

code

public class localize : actionfilterattribute {     public override void onactionexecuting(actionexecutingcontext filtercontext)     {         // .. irrelevent logic here ..          // set redirect code 301         filtercontext.httpcontext.response.status = "301 moved permanently";         filtercontext.httpcontext.response.statuscode = 301;          // redirect         filtercontext.result = new redirectresult("/" + cookielanguage);          base.onactionexecuting(filtercontext);     } } 

proof

enter image description here

redirectresult has constructor overload takes url , bool indicate if redirect should permanent:

filtercontext.result = new redirectresult("/" + cookielanguage, true); 

from can see, should available in mvc 4.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -