A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories.
Hi @Arshad Nazeer,
You can count the number of user visits to your site in Program.cs like below:
var app = builder.Build();
int visitCount = 0;
app.Use(async (context, next) =>
{
// Increment visit count for every request
visitCount++;
Console.WriteLine(visitCount);
// Pass the request to the next middleware
await next.Invoke();
// You can perform additional actions after the response is sent
});
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllers();
app.Run();
If you need to persist the visit count, you might consider using a database or another persistent storage solution.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Rena