I have a display template in MVC that is for a collection of items, so the first line of my cshtml
file is as follows:
@model IList<Some.Namespace.ViewModels.MyListItem>
If I add some new HTML to the file and then do CTRL + K + D
to auto format, it now changes my model to all lower case like this:
@model IList<some.namespace.viewmodels.mylistitem>
This is a massive pain to keep changing after auto formatting, because it obviously breaks my html helpers until I correct the casing. I found this question and it said it was due to MVC3.
I'm running VS2013 Update 4 with MVC5 and I still have this problem. I can't find anything in the Text Editor options to change this behaviour.
I'm also using ReSharper 8.2 and Web Essentials 2013 for Update 4.
Is this a known issue or do I have a setting that is breaking things somewhere?
This is what you need to do to fix the formatting issue.
In the web.config
of Views folder overwrite MvcWebRazorHostFactory
with this line
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Close Any open cshtml files and open them.Now formatting the document should work fine, Also I had intellisense problem in razor page which was also resolved. I tried both and did not have any problem.
If you still encounter problems let me know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With