locked
Operation is not supported on this platform. RRS feed

  • Question

  • User514892507 posted
    In application_BeginRequest i add Request header like this: NameValueCollection headers =HttpContext.Current.Request.Headers; Type t = headers.GetType(); PropertyInfo p = t.GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); p.SetValue(headers, false, null); //add a header headers.Add("UserName", "qa"); But when i try to retrieve this header from an asp page like this: Request.ServerVariables("HTTP_UserName") I get the Operation is not supported on this platform error. Thanks in advance
    Tuesday, May 26, 2009 2:54 AM

Answers

  • User1779468316 posted

    In application_BeginRequest i add Request header like this: NameValueCollection headers =HttpContext.Current.Request.Headers; Type t = headers.GetType(); PropertyInfo p = t.GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); p.SetValue(headers, false, null); //add a header headers.Add("UserName", "qa"); But when i try to retrieve this header from an asp page like this: Request.ServerVariables("HTTP_UserName") I get the Operation is not supported on this platform error. Thanks in advance

    My previous reply was to the bolded statement in your original post:

    The reason you get an error on that statement is because it is an accessor, not a method call. Thus the correction is to use sqare brackets, '[]' instead of parens, '()'.

    Your incorrect version: Request.ServerVariables("HTTP_UserName");

    The correct version: Request.ServerVariables["HTTP_UserName"];

    Eric

    http://www.my-msi.net

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 31, 2009 1:07 PM

All replies

  • User1779468316 posted

    You might want to try:

    Request.ServerVariables["HTTP_UserName"];

    That at least compiles cleanly whereas using parens "()" resulted in a compilation error in C# which I believe you are using.

    Eric

    http://www.my-msi.net

     

    Saturday, May 30, 2009 4:58 PM
  • User1677448765 posted

    ur code is not clear.. can u post ur article again..

    Sunday, May 31, 2009 3:43 AM
  • User1779468316 posted

    In application_BeginRequest i add Request header like this: NameValueCollection headers =HttpContext.Current.Request.Headers; Type t = headers.GetType(); PropertyInfo p = t.GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); p.SetValue(headers, false, null); //add a header headers.Add("UserName", "qa"); But when i try to retrieve this header from an asp page like this: Request.ServerVariables("HTTP_UserName") I get the Operation is not supported on this platform error. Thanks in advance

    My previous reply was to the bolded statement in your original post:

    The reason you get an error on that statement is because it is an accessor, not a method call. Thus the correction is to use sqare brackets, '[]' instead of parens, '()'.

    Your incorrect version: Request.ServerVariables("HTTP_UserName");

    The correct version: Request.ServerVariables["HTTP_UserName"];

    Eric

    http://www.my-msi.net

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 31, 2009 1:07 PM
  • User514892507 posted
    As mentioned in question i am trying to retrieve it from an ASP page not a C# page thats why i am using ().Do you still want me to try with [] in an ASP page.
    Tuesday, June 2, 2009 3:40 AM