Using codecs file extensions with OpenRasta returns 404

When using uric uric file extensions with OpenRasta, OR cannot resolve uri and returns 404. Without the file extension, everything works fine.

Codecs are defined for an object resource, and I use both XmlDataContract and JsonDataContract. Using neither the .xml extension nor the .json extension, this works for both InMemoryHost (which we use for testing) and ASP.Net (IIS7, native mode).

Codec configuration:

ResourceSpace.Has.ResourcesOfType<object>()
                .WithoutUri
                .AsXmlDataContract()
                .And.AsJsonDataContract();

Is there anything else that needs to be done to expand the uri files?

+3
source share
1 answer

You need to register ContentTypeExtensionUriDecorator as UriDecorator in OpenRasta in order to output .xml, .json functionality.

http-:

GET/home.json

GET/home.xml

public class RastaConfig : IConfigurationSource
{
    public void Configure()
    {
        using(OpenRastaConfiguration.Manual)
        {
            ResourceSpace.Uses.UriDecorator<ContentTypeExtensionUriDecorator>();

            ResourceSpace.Has.ResourceOfType<Home>()
                .AtUri("/home")
                .HandledBy<HomeHandler>()
                .AsXmlDataContract()
                .And.AsJsonDataContract();
        }
    }
}

, noramlly HTTP Accept , .

( conneg) .

OpenRasta HTTP Accept.

, .

+4

Source: https://habr.com/ru/post/1791179/


All Articles