Skip to content

Request.Files is empty on Mono Self Host #271

@scottmcarthur

Description

@scottmcarthur

When using self hosting on Mono, Request.Files is always empty.

I am using 4.0.39 with the code I had previously used here. I have tried Chrome, Safari and Postman, same result.

using System;
using ServiceStack;

namespace Testv4
{
    class MainClass
    {
        public static void Main()
        {
            var appHost = new AppHost(500);
            appHost.Init();
            appHost.Start("http://*:8082/");
            Console.ReadKey();
        }
    }

    public class TestApp
    {
        [Route("/upload", "POST")]
        public class UploadFileRequest {}

        public class TestController : Service
        {
            public void Any(UploadFileRequest request)
            {
                Console.WriteLine(Request.Files.Length); // Always 0
            }
        }
    }

    public class AppHost : AppHostHttpListenerPoolBase
    {
        public AppHost(int poolSize) : base("Test Service", poolSize, typeof(TestApp).Assembly)
        {
        }

        public override void Configure(Funq.Container container)
        {
        }
    }
}

The html:

<!doctype html>
<html>
<head>
    <title>Test</title>
</head>
<body>
<form action="/upload" method="POST" enc="multipart/form-data">
    <h1>Upload File</h1>
    <input type="file" name="File1" />
    <input type="submit" value="Upload" />
</form>
</body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions