Closed moustafa11911 closed 3 years ago
This is likely caused by the fact that you need to return a string in the else clause. Can you try returning a string in the else clause?
thanks for reply, I use a default string at the end and the same issue exists
app.RunProxy(proxy =>
proxy.UseHttp((context, args) =>
{
if (context.Request.Path.StartsWithSegments("/api/yy"))
return Configuration["AppSettings:ApiUrl"];
return Configuration["AppSettings:DefultApiUrl"];
}));
Interesting. Can you try debug-printing those strings before you return them? Is it possible the Configuration is empty?
I checked the configuration and it is as the following
Configuration["AppSettings:ApiUrl"] => https://localhost:5001 Configuration["AppSettings:DefultApiUrl"] => https://localhost:3001
Ok, thanks!
Did you print those values from within that closure? Basically, I want to know if the code inside that closure ever gets hit. If it does, then something along context.Request.Path
is null
.
If it doesn't, then it is clear the problem is here. Which means that, somehow, context.GetRouteData().Values
is null
.
It looks like GetRouteData()
can be null, so that may be the culprit. I will push a patch, and you can try it out!
Can you please try the updated package?
Ok, will try it now
Fixed now, thanks a lot for your great support.
Hello, I am getting this exception when run proxy
System.NullReferenceException: Object reference not set to an instance of an object. at AspNetCore.Proxy.Basic.GetEndpointFromComputerAsync(HttpContext context, EndpointComputerToValueTask computer) at AspNetCore.Proxy.HttpExtensions.ExecuteHttpProxyOperationAsync(HttpContext context, HttpProxy httpProxy) at AspNetCore.Proxy.Basic.ExecuteProxyOperationAsync(HttpContext context, Proxy proxy) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication
1 application)`the proxy code
I install latest package V 4.2.0 on my project which run using .NetCore 2.2 waiting your help as this is a showstopper issue. Thanks.