Remove unused using Microsoft.AspNetCore.Mvc.Rendering from Index.cshtml.cs scaffolding snippets#36842
Remove unused using Microsoft.AspNetCore.Mvc.Rendering from Index.cshtml.cs scaffolding snippets#36842
using Microsoft.AspNetCore.Mvc.Rendering from Index.cshtml.cs scaffolding snippets#36842Conversation
…shtml.cs snippetFullFirstGenerated blocks Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com>
using Microsoft.AspNetCore.Mvc.Rendering from Index.cshtml.cs scaffolding snippets
|
@copilot, you removed a line of code in 2 files. Those 2 files are referenced by the tutorial articles series in this location and often refer to line numbers when highlighting code lines form that code that is included as an include file. Verify if the highlighting or any other paramameters specifying lines of code for those to code files as includes are still correct. If not, fix them. aspnetcore/tutorials/razor-pages/ |
Verified all references to both modified files across The only |
|
Verified removed code lines did not change the display in the tutorial improperly. All good. |
The
snippetFullFirstGeneratedblock in the Razor Pages tutorial'sIndex.cshtml.csincludedusing Microsoft.AspNetCore.Mvc.Rendering, which the old scaffolder's Index template does not generate (only Create/Edit templates do). This caused a mismatch between the docs and what users see when following the tutorial.using Microsoft.AspNetCore.Mvc.Rendering;from thesnippetFullFirstGeneratedblock in:snapshot-sample10/Pages/Movies/Index.cshtml.cs(aspnetcore-10.0)snapshot_sample9/Pages/Movies/Index.cshtml.cs(aspnetcore-9.0)SEARCH_NEWPROPS,FIRST_GENERATED_INDEX) retainMvc.RenderingsinceSelectListis used thereOriginal prompt
This section details on the original issue you should resolve
<issue_title>Remove unused usings</issue_title>
<issue_description>### Description
These are the only three namespaces I need for the Index page:
You might want to right click on the using statements at the top of all your pages and select "Remove and Sort Usings" to get rid of unneeded usings.
As you write code if you let intelligence finish off class names [hit tab] the VS IDE automatically inserts the needed using statement back in.
Page URL
https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/page?view=aspnetcore-10.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/razor-pages/page.md
Document ID
15e79e80-8d46-7cd5-c883-6cc0f5940a1b
Platform Id
c731bb82-fefd-1cfc-91d3-8ea9527d2680
Article author
@wadepickett
Metadata
Related Issues</issue_description>
<agent_instructions>There is important additional information and direction in the discussion for this issue, in addtion to the issue description. Read all of it before considering the action to take. </agent_instructions>
Comments on the Issue (you are @copilot in this section)
@wadepickett Thanks @smiller7812 for taking the time to file this issue. You are right, that should be reviewed.The tutorial does need to reflect what the developer would see on their own screen when project or scaffolding templates are used. The templates in some cases put in using statements that would be useful, but are not used in the focused tutorial example. I would guess however there are some in there that are not added by the templates, and yet not used. I'll check.</comment_new>
<comment_new>@wadepickett
🤖 AI Triage Summary
This preliminary assessment report was run by: @wadepickett
Date: 2026-03-05
Issue: 36838
Model: GitHub Copilot
Issue Analysis: Remove unused usings from Razor Pages tutorial code samples
✅ Issue Validation
Status: Valid — but requires nuanced action based on scaffolding template analysis
📋 Issue Summary
The issue requests removing unnecessary
usingstatements from code samples in the Razor Pages tutorial. However, investigation of the actual ASP.NET Core scaffolding templates indotnet/Scaffoldingreveals that theusingstatements present in the documentation samples are intentionally generated by the scaffolding tooling that the tutorial instructs users to run. The tutorial should match what users actually see when following along.Key Finding: Two Generations of Scaffolding Templates
The
dotnet/Scaffoldingrepository contains two scaffolding codepaths:VS.Web.CG.Mvc/aspnet-codegenerator)dotnet aspnet-codegeneratorCLISystem;,System.Collections.Generic;,System.Linq;,System.Threading.Tasks;,Microsoft.AspNetCore.Mvc.Rendering;, etc.dotnet-scaffold/ T4 templates undernet10.0/)dotnet scaffold aspnet razorpages-crudCLIMicrosoft.AspNetCore.Mvc;,Microsoft.AspNetCore.Mvc.RazorPages;,Microsoft.EntityFrameworkCore;+ dynamic model/context namespacesEvidence from the old scaffolder templates (
CreatePageModel.cshtml):Evidence from the new .NET 10 scaffolder templates ([
IndexModel.tt](https://github.com...✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.