Questions tagged [actionmethod]

Action methods typically have a one-to-one mapping with user interactions. Examples of user interactions include entering a URL into the browser, clicking a link, and submitting a form. Each of these user interactions causes a request to be sent to the server. In each case, the URL of the request includes information that the MVC framework uses to invoke an action method.

Most action methods return an instance of a class that derives from ActionResult. The ActionResult class is the base for all action results. However, there are different action result types, depending on the task that the action method is performing. For example, the most common action is to call the View method. The View method returns an instance of the ViewResult class, which is derived from ActionResult.

You can create action methods that return an object of any type, such as a string, an integer, or a Boolean value. These return types are wrapped in an appropriate ActionResult type before they are rendered to the response stream.

135 questions
1
vote
0 answers

How to call a specific function before Action Method execution in web API?

I have a requirement to validate 2 paramaters before all Action method execution in WEB API2. Let say my vallidation is like , Every action method must have 2 non empty paramaters named - A and B. A must be greater than B and both should exists…
user1926138
  • 1,464
  • 7
  • 34
  • 53
1
vote
0 answers

Cost of using multiple filter attributes on an action method

We have several filter attributes on action methods - HandleExceptionAttribute: To log and return InternalServerError in case of an exception. ValidateModelAttribute: To return BadRequest if ModelState is not valid. AuthorizationAttribute: simple…
1
vote
2 answers

Call an action method when session ends

I want to call LogOut action method whose View i have not created as the session times out. I have written a script for session time out but i dont know how to call action method because all the methods i have got like window.location etc locates…
Dashanan
  • 122
  • 3
  • 16
1
vote
1 answer

Call an action from another action without return statement

This is part of my Controller class: if (ds.Tables.Count > 1) { if (ds.Tables[0].Rows.Count > 0) { dt = ds.Tables[0]; dr = dt.Rows[0]; TempData["AgentId"] = dr[0].ToString(); TempData["AgentCode"] =…
Dashanan
  • 122
  • 3
  • 16
1
vote
2 answers

Trying to call an action method results in view error

I have 3 actionResults in one controller, and I want all actionResults return one view as the code below: In controller: public ActionResult Index() { return View(ListGroup); } [HttpPost] public ActionResult…
Tran Duy Linh
  • 221
  • 1
  • 9
1
vote
2 answers

How to return a single string to a div in my current page from HTTP POST in ASP.NET MVC 5?

I'm trying to post a message after a contact form, indicating to the user that their message has been sent after they click the submit button. I don't want to redirect to a different page or to return a different view inside my HTTP Post action…
Lula la
  • 13
  • 7
1
vote
0 answers

ASP.NET MVC5 Controller Action Takes 4 Seconds Or So

I have two views: Product/List, which displays a list of products, and Product/Details/{id}, which displays the details of the product of the given Id. Every time when a user clicks on a product item on the Product/List view to go to the…
Stack0verflow
  • 1,148
  • 4
  • 18
  • 42
1
vote
1 answer

redirect to action of different controller not retaining variable

I'm redirecting from one controller to another, and sending over an object in the route values but the object is coming back as null: class Person { string Name {get; set;} } FirstController { ActionResult something() { Person p = new Person()…
Mahmud Ahmad
  • 171
  • 3
  • 18
1
vote
1 answer

Last Action/Url finder ASP.NET MVC 5

Ok, first off I want to say that I have no idea what I'm doing. I have several pages in my MVC project that constantly get hit from a different page. For instance my Edit page for one of my Models can come from an admin link on a detail page or the…
Eric Bishard
  • 5,201
  • 7
  • 51
  • 75
1
vote
2 answers

Error during serialization using the JSON JavaScriptSerializer. Should be using the JSON.NET JsonSerializer

I've added Newton Soft to the mix and am using this blog as a template: http://wingkaiwan.com/2012/12/28/replacing-mvc-javascriptserializer-with-json-net-jsonserializer/ I now have: public class BaseJsonController : BaseController { protected…
Keith Barrows
  • 24,802
  • 26
  • 88
  • 134
1
vote
2 answers

How to "hook" into the pipe where the argument/object gets passed to the action-method

Is there any way to alter the passed object to an action-method before it actually enters/(gets passed to) the action-metod?.. For instance... By default I want the Index()-action-method to always take an argument of MyClass.. So.. if a user visit…
Inx
  • 2,364
  • 7
  • 38
  • 55
1
vote
2 answers

Pass ViewModel + Parameter to action using ajax call

How do I pass a view model and another parameter to my action method using jquery ajax? with what I'm doing now, the action method is not being called. I think the cause is probably because the parameters are not being passed correctly in the data…
vobs
  • 133
  • 1
  • 5
  • 16
1
vote
1 answer

How to call a bean method when mouse over on a graphicImage?

I have the requirement that on mouse over of a a JSF backing bean method should be called which will display some data dynamically. How can I achieve this? Please don't suggest me JavaScript code.
Venkat Maridu
  • 892
  • 3
  • 22
  • 45
1
vote
2 answers

Adding a post outside of a form

I have a form in my razor view which works exactly as it should. I select values from the drop down and press the submit button and it return to me a paginated set of results. All well and good. @using (Html.BeginForm()) { int index =…
Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
1
vote
2 answers

How to organize controller class and action method?

Suppose I am working on a Car Portal. To search a new car, the user provides the following information: Brand Model ModelVersion FuelType Budget Business Rules: If user selects Brand only : Show brand list page with all models of selected…
Paul
  • 457
  • 2
  • 11
  • 26
1 2 3
8 9