I'm trying to use VS more efficiently, and I was looking for a way to generate a method automatically. For example, I know if you type foreach
then press TAB
twice it generates the skeleton code, so if I had a method like this:
[HttpPost]
public ActionResult CloseTicket()
{
//do stuff
}
Is there a way of generating the 'skeleton code' so I don't have to manually type it out. I looked into method stubs but they don't seem to apply to this.
An action result is what a controller action returns in response to a browser request. The ASP.NET MVC framework supports several types of action results including: ViewResult - Represents HTML and markup. EmptyResult - Represents no result.
Html. ActionLink creates a hyperlink on a view page and the user clicks it to navigate to a new URL. It does not link to a view directly, rather it links to a controller's action.
The NonAction attribute is used when we want a public method in a controller but do not want to treat it as an action method. An action method is a public method in a controller that can be invoked using a URL. So, by default, if we have any public method in a controller then it can be invoked using a URL request.
There are built-in snippets in Visual Studio to help with this:
mvcaction4
inserts:
public ActionResult Action()
{
return View();
}
And
mvcpostaction4
Inserts
[HttpPost]
public ActionResult Action()
{
return View();
}
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