I was realizing that I need to write some middleware for httpcontext etc.., but thus I tried to take even an example from Microsoft, and the problem is that even with breakpoints on the outside ... app.Use
and app.Run
, with F11 it will not step into the code.
How can I even step into this code to see the values?
startup.cs file
public void Configure(IApplicationBuilder app)
{
var request = new Request("api/menu/create", Method.POST);
request.AddParameter("currentApplicationId", 1, ParameterType.QueryString);
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
// UPDATE : Code above prevented from being able to step into below?
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.Use((context, next) =>
{
var cultureQuery = context.Request.Query["culture"];
if (!string.IsNullOrWhiteSpace(cultureQuery))
{
var culture = new CultureInfo(cultureQuery);
CultureInfo.CurrentCulture = culture;
CultureInfo.CurrentUICulture = culture;
}
// Call the next delegate/middleware in the pipeline
return next();
});
app.Run(async (context) =>
{
await context.Response.WriteAsync(
$"Hello {CultureInfo.CurrentCulture.DisplayName}");
});
}
next()
instead ofreturn next();
Please give a try with that and let me know. – Cappuccinoapp.UseMvc
should be the last middleware in the pipeline. Please also update this and give a try. – Cappuccinoapp.UseMvc(..
to be last . Thanks – Frankereturn next()
withnext()
? – Cappuccinonext
, complains about needing a return on the lambda=>
– Franke