Developer technologies | ASP.NET | ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want write "Hello World" with ASP.NET Core. Can you help me?
A set of technologies in the .NET Framework for building web applications and XML web services.
Answer accepted by question author
HomeController.cs file (for MVC) or Index.cshtml.cs file (for Razor Pages) in the Controllers or Pages folder, respectively. Write the following code to display "Hello World":For MVC
using Microsoft.AspNetCore.Mvc;
namespace YourNamespace.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return Content("Hello World");
}
}
}
For Razor Pages:
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace YourNamespace.Pages
{
public class IndexModel : PageModel
{
public void OnGet()
{
ViewData["Message"] = "Hello World";
}
}
}
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin