Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Fix registration of MVC services #2648

Closed
@kichalla

Description

@kichalla

Ideally both of the following configurations should work…i.e a user should be able to call ‘ConfigureMvc’ either before or after AddMvc() and all the options registered would get called in the sequence they were registered.
Currently the issue is that #2 does not work as AddMvc() call doesn’t add options if it was added earlier.

  1. public IServiceProvider ConfigureServices(IServiceCollection services)
    {
    services.AddMvc();

services.ConfigureMvc(options =>
{
// This adds both Input and Output formatters based on DataContractSerializer
options.AddXmlDataContractSerializerFormatter();

// To add XmlSerializer based Input and Output formatters.
options.InputFormatters.Add(new XmlSerializerInputFormatter());
options.OutputFormatters.Add(new XmlSerializerOutputFormatter());

});
2. public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.ConfigureMvc(options =>
{
// This adds both Input and Output formatters based on DataContractSerializer
options.AddXmlDataContractSerializerFormatter();

// To add XmlSerializer based Input and Output formatters.
options.InputFormatters.Add(new XmlSerializerInputFormatter());
options.OutputFormatters.Add(new XmlSerializerOutputFormatter());

});

services.AddMvc();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions