[AI-Suggested] Content update request from UUF signal: Part 2, add a controller to an ASP.NET Core MVC app | Microsoft Learn

Aperta Adatta ai principianti
#37,991 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
documentation

Direzione di ricerca

Modifica aspnetcore/tutorials/first-mvc-app/adding-controller.md, il file sorgente indicato nell’issue. Inizia verificando i passaggi di scaffolding di Visual Studio e l’esempio HelloWorldController.cs in base al comportamento attuale di Visual Studio e alle istruzioni circostanti del tutorial. Aggiorna il punto di ingresso e la nota per la risoluzione dei problemi, poi rendi coerenti l’esempio del controller e la relativa spiegazione. Il lavoro è completato quando entrambi gli aggiornamenti richiesti sono chiari e il blocco di codice compila così come è scritto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

:watch: Not Triaged CAC

Documentation Update: Part 2, add a controller to an ASP.NET Core MVC app | Microsoft Learn

Customer Feedback

Page: Part 2, add a controller to an ASP.NET Core MVC app | Microsoft Learn
Source File: https://github.com/dotnet/AspNetCore.Docs/blob/live/aspnetcore/tutorials/first-mvc-app/adding-controller.md

Summary

Update the “Add a controller” instructions to match current Visual Studio UI/scaffolding entry points and refresh the sample controller code to reflect the default scaffolded action signatures (IActionResult) or explicitly explain why the tutorial uses string returns.

Suggested Fixes

Instructions for Copilot: Copilot should only fix suggestions with a checkmark and do not make any updates for unchecked suggestions.

[!NOTE]
Suggestions are generated by AI and they should be reviewed by human before assigning it to Copilot. Please uncheck the ones you don't want Copilot to work on. Then assign this issue to Agent (GitHub Copilot). When assigning it to Copilot you can enter additional instructions under "Optional Prompt" dialog.

  • In the “Add a controller” (Visual Studio) subsection, update the UI/scaffolding steps to reflect current Visual Studio behavior and add a short troubleshooting note for users who don’t see “Add New Scaffolded Item”. Concretely: (1) verify and update the exact menu path/screenshots for the latest VS (e.g., right-click Controllers > Add > Controller… and/or Add > New Scaffolded Item… depending on version); (2) add a callout listing prerequisites that make scaffolding appear (ASP.NET and web development workload installed; correct project type/template; optional: individual components like scaffolding tools). Include an explicit “If you don’t see it” paragraph under the existing screenshot.

    Example add-on text (place immediately after the ‘right-click Controllers > Add > Controller’ step):
    If you don’t see Controller… or Add New Scaffolded Item, confirm you installed the ASP.NET and web development workload in Visual Studio Installer. Also ensure you’re in an ASP.NET Core Web App (Model-View-Controller) project (not Minimal API/Empty). In some Visual Studio versions, the entry point appears as Add > New Scaffolded Item… instead of Add > Controller….

  • Update the HelloWorldController code in the “Replace the contents of Controllers/HelloWorldController.cs” block (and the paragraph that says “both methods return a string”) to align with the controller/action signature users get from modern templates (commonly IActionResult or ActionResult<string>). Either (A) change the sample to use IActionResult + Content() so it matches scaffolded output, or (B) keep string but add a clear note explaining that this tutorial intentionally uses string for simplicity and that scaffolding may generate IActionResult by default. Provide one canonical code block that compiles as-is.

    Example replacement code (recommended, matches IActionResult):

    using Microsoft.AspNetCore.Mvc;
    using System.Text.Encodings.Web;
    
    namespace MvcMovie.Controllers;
    
    public class HelloWorldController : Controller
    {
        // GET: /HelloWorld/
        public IActionResult Index()
        {
            return Content("This is my default action...");
        }
    
        // GET: /HelloWorld/Welcome/
        public IActionResult Welcome()
        {
            return Content("This is the Welcome action method...");
        }
    }
    

    And update the explanatory sentence to: “In the sample above, both methods return an IActionResult using Content() to produce a plain-text response.”


📚 To learn more about agentic content maintenance workflow, visit Agentic workflow for Learn content maintenance. Sign in using Learn Profile to access the content on this link.

💬 Share your feedback on the Learn Content Maintenance Agentic Workflow here.

Lingua principale
C#
Stelle
13.1k
Fork
24.5k
Merge medio
3g 2h
PR unite (30g)
210

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnet/AspNetCore.Docs

Tutte le issue di dotnet/AspNetCore.Docs

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.