I am making a Restful api using OData, and for some reasons I want to force the expand filtering inside the middleware.
So if the clients sends in
The Middleware should automatically change it into
http://localhost:52973/odata/customers?$expand=Contact,Address
In order to do this I've made a simple if statement inside my middleware
if (ctx.Request.Path.Value.Contains("customers") && !ctx.Request.QueryString.Value.Contains("?$expand"))
{
string uri = @"?$expand=";
ctx.Request.QueryString = ctx.Request.QueryString.Add(uri, "Contact,Address");
}
Unfortunately, it keeps generating the following: {?%3F%5C$expand%5C%3D=Contact,Address}
I've tried adding backslashes inside the uri string, but that didn't solve it.