I am using Visual Studio 2017. I can expand and collapse in .cs files using command as follows:
Expand CTRL+M+L
Collapse CTRL+M+O
But same is not working in .cshtml file? Is there any workaround?
From what I could determine, Visual Studio doesn't support expanding and collapsing for this file type.
There is a sort of workaround, although it has its limitations. You can manually select regions in a given file that you'd like to hide and press Ctrl+MCtrl+H (also found in the Edit->Outlining menu) to hide them. Visual Studio will "remember" that you want these specific regions to be hideable, and you can now show and hide these sections with the outlining commands (for example Ctrl+MCtrl+A will hide all sections, and Ctrl+MCtrl+X will show all sections, depending on your keybindings).
This isn't a perfect solution by any means, because you need to set up the regions manually. But it might come in handy in some cases.
Here's an example of a .cshtml file after I set up the regions:
...and after pressing Ctrl+M+L once: