Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why mvcaction4 code snippet does not react?

When I write mvcaction4 and press tab 2 times it doesn't work. Currently I am using Visual Studio 2017 Community Edition.

like image 551
TuralAsgar Avatar asked Mar 12 '17 14:03

TuralAsgar


People also ask

How do I enable react snippets in Visual Studio code?

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.


3 Answers

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>
like image 126
JordanGW Avatar answered Oct 19 '22 19:10

JordanGW


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

enter image description here

like image 30
Jacques Eloff Avatar answered Oct 19 '22 21:10

Jacques Eloff


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:

  1. Assume you have already installed both Visual Studio 2015 and Visual Studio 2017.
  2. Open Visual Studio 2017, then click menu [Tools] -> [Code Snippets Manager]
  3. Switch Language to CSharp in the Code Snippets Manager window
  4. Hit the Import button
  5. Enter C:\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 )
  6. Hit Finish button to complete import.
like image 25
Will Huang Avatar answered Oct 19 '22 19:10

Will Huang