The question was how I can now intercept calls like
www.infovalutar.ro/bnr/2004/10/10/EUR
www.infovalutar.ro/bnr/azi/eur
www.infovalutar.ro/2004/6/4/eur.bnr
http://www.infovalutar.ro/bnr/rss
? There is no controller ! So – middleware to help!
For reading about middleware,please see https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-3.0
For rewriting,please see https://docs.microsoft.com/en-us/aspnet/core/fundamentals/url-rewriting?view=aspnetcore-3.0
Anyway,this is my code:
var service = app.ApplicationServices.GetService<LoadExchangeProviders>();
foreach (var item in service.Banks())
{
app.MapWhen(cnt =>
cnt.Request.Path.Value.StartsWith(“/” + item + “/”,StringComparison.InvariantCultureIgnoreCase)
||
cnt.Request.Path.Value.EndsWith(“.” + item,StringComparison.InvariantCultureIgnoreCase)
,HandleBank);
}
Figures also that previous answer was a string,not an object – changing return type to string
Leave a Reply