简体   繁体   中英

How to print process name in StartUp.cs for .net core 3.1

From yesterday I have started learning .netcore . I have installed .netcore 2.2 & .netcore 3.1 in my machine.

In .netcore 2.2 , I am able to print the process name on the website. ie I had written this below code in Startup.cs in an empty .netcore web application:

app.Run(async (context) =>
{
    await context.Response
    .WriteAsync(System.Diagnostics.Process.GetCurrentProcess().ProcessName);
});

But now in .netcore 3.1 , by default, it is calling the razor pages. So, I tried to replace that code with the above code, but I am getting this below error:

'HttpResponse' does not contain a definition for 'WriteAsync' and no accessible extension method 'WriteAsync' accepting a first argument of type 'HttpResponse' could be found (are you missing a using directive or an assembly reference?

It seems the extension method ' WriteAsync ' has been removed in .netcore 3.1 .

So, how do I display that now?

添加这个使用

using Microsoft.AspNetCore.Http;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM