When I write mvcaction4
and press tab
2 times it doesn't work. Currently I am using Visual Studio 2017 Community Edition.
Here's how to use React Snippets in VSCode:Go to Code, then Settings, then Extensions. Search for React Snippets. There are many good snippet extensions to choose from.
I had this same problem so I followed Will Huang's answer but created my own snippet. I will leave the code snippet below.
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets >
<CodeSnippet Format="1.0.0">
<Header>
<Title>mvcaction</Title>
<Shortcut>mvcaction</Shortcut>
<Description>Code snippet for an MVC Action</Description>
<Author>Jordan Gregory-Wallis</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Action Name</ToolTip>
<Default>Action</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[public ActionResult $name$()
{
return View();
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
MVC4 snippets are supported in VS2017. MVC 4 is an optional component that's part of the web workload. If you don't have it installed and try to open an MVC 4 project it should prompt you to add the missing component to Visual Studio.
Support for MVC 4 is limited. We don't allow you to create new MVC 4 projects, but you can - Open existing MVC 4 projects - Scaffold controllers/views - Use snippets
EDIT MVC4 snippets will only show up for an MVC 4 project. The snippets are tied to the .csproj/.vbproj ProjectTypeGuid properties.
Below is a screenshot from MVC4 snippets in VS2017
I think the mvcaction4
and mvcpostaction4
snippets has been removed from Visual Studio 2017.
All you can do is to import these snippets from Visual Studio 2015. Here is the steps you can do:
CSharp
in the Code Snippets Manager windowImport
buttonC:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Visual Studio 2015\Snippets\VC#\1033\ASP.NET MVC 4
and select all items ( mvcaction.snippet
and mvcpostaction.snippet
)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