2

The razor view formatting is so bad even when I tried ctrl k + ctrl d

the page is so missed up

any help, please!

enter image description here

     @if (item.Details.Length > 10)
                        {
    @item.Details.ToString().Substring(0, 10) }
else
{
@item.Details}
phuzi
  • 12,078
  • 3
  • 26
  • 50
Mohaned Ghawar
  • 73
  • 1
  • 10

1 Answers1

2

You can enable the new Razor editor first, and then restart VS.

Then you can choose Edit->Advanced->Format Document.

enter image description here

✎[Edit]

You can try the following methods:

  1. Check whether three-party plug-ins are installed.
    • If there are three-party plug-ins installed, temporarily disable them, and then test it.
  2. You can try reset VS settings.
  3. Repair VS (repair in VS Installer)
  4. Create a new project and check if the same problem occurs.
  5. Clean up the program /project/VS cache, then restart VS and try again.
    • The project is cached in the solution/project folder,you need to delete the bin, obj and .vs files.
    • VS is cached in this path: C:\Users[user name]\AppData\Local\Microsoft\VisualStudio\16.0_XXXXXXXXX, delete all ComponentModelCache folder.
  6. Give feedback to the VS product group from VS-> Help-> Send Feedback-> Report a Problem...
Yihui Sun
  • 755
  • 3
  • 5
  • This is very strange. The version of VS I am currently using is 16.9.2 (but not the latest version). You can see that I can format the code correctly. I suggest you can try again after updating the latest version of VS. The problem you encounter may be caused by the version of VS you are using. – Yihui Sun Jun 16 '21 at 06:44
  • I have the latest version of VS and the problem still there. – Mohaned Ghawar Jun 16 '21 at 12:54
  • I updated the reply, you can check it out. – Yihui Sun Jun 17 '21 at 02:31