Share via


DefaultFormatHelper Class

 

Represents the default implementation of FormatHelper The results for GetRequestFormat() and GetResponseFormats() are cached on the HttpContext.Items dictionary: HttpContext.Items["requestFormat"] HttpContext.Items["responseFormat"].

Namespace:   Microsoft.Web.Mvc.Resources
Assembly:  Microsoft.Web.Mvc (in Microsoft.Web.Mvc.dll)

Inheritance Hierarchy

System.Object
  Microsoft.Web.Mvc.Resources.FormatHelper
    Microsoft.Web.Mvc.Resources.DefaultFormatHelper

Syntax

public class DefaultFormatHelper : FormatHelper
public ref class DefaultFormatHelper : FormatHelper
type DefaultFormatHelper = 
    class
        inherit FormatHelper
    end
Public Class DefaultFormatHelper
    Inherits FormatHelper

Constructors

Name Description
System_CAPS_pubmethod DefaultFormatHelper()

Initializes a new instance of the DefaultFormatHelper class.

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetRequestFormat(RequestContext)

Returns the format of a given request, according to the following rules: 1. If a Content-Type header exists it returns a ContentType for it or fails if one can't be created 2. Otherwise, if a Content-Type header does not exists it provides the default ContentType of "application/octet-stream" (per RFC 2616 7.2.1).(Overrides FormatHelper.GetRequestFormat(RequestContext).)

System_CAPS_pubmethod GetResponseFormats(RequestContext)

Returns the preferred content type to use for the response, based on the request, according to the following rules: 1. If the RouteData contains a value for a key called "format", its value is returned as the content type 2. Otherwise, if the query string contains a key called "format", its value is returned as the content type 3. Otherwise, if the request has an Accepts header, the list of content types in order of preference is returned 4. Otherwise, if the request has a content type, its value is returned (Overrides FormatHelper.GetResponseFormats(RequestContext).)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod IsBrowserRequest(RequestContext)

Determines whether the specified HTTP request was sent by a Browser.(Overrides FormatHelper.IsBrowserRequest(RequestContext).)

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

Fields

Name Description
System_CAPS_pubfieldSystem_CAPS_static RequestFormatKey

Represents the request format key.

System_CAPS_pubfieldSystem_CAPS_static ResponseFormatKey

Represents the response format key.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Microsoft.Web.Mvc.Resources Namespace

Return to top