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
0
votes
1 answer

MVC5 Getting a button to call an action method in Controller

As the heading states when I click a button on my main view I need it to call a method in my controller for that view. Ive been trying for hours and Ive changed the specific lines of code many times but all variations seem to give the same errors so…
0
votes
0 answers

I am using simple cart js for my cart in asp.net mvc

I am using simpleCart js for my ecommerce project in asp.net mvc. All is going well and items are stored in cart. Basically the cart is storing items in local storage of client browser. I have a anchor tag on which user will clik and go to check out…
0
votes
1 answer

How to call some Controller's method and pass a parameters from a query string

in my app I've generated an url like this: http://www.test.com/?mail=test%40gmail.ba&code=71147ff9-87ae-41fc-b53f-5ecb3dbe5a01 The way how I generated Url is posted below: private string GenerateUrl(string longUrl, string email, string…
billy_56
  • 649
  • 3
  • 11
  • 27
0
votes
1 answer

Is it possible to send Model data from a View to a Controller that is not the Controller for that View?

I could not find the similar question yet, so I decided to ask it here. I relatively new to MVC and may have some incorrect wording in my question, and I'm just wondering if that is possible to do it at all? Usually, we are dealing with…
gene
  • 2,098
  • 7
  • 40
  • 98
0
votes
0 answers

Select action for refresh ASP.NET MVC

Can you determine which action will be used when you refresh the page? I am using PRG pattern in my ASP.NET MVC web application. I have 4 dropdowns in my view for selecting item x and item y 2 for groups x and y and 2 for items x and y within group…
user8816462
0
votes
2 answers

Model object not getting values in controller actionMethod

I'm new to Asp.Net MVC. I am facing this issue that I have strongly typed input fields in view file. When I send ajax call to controller acion-method, model objects do not get any value. My code is attached. View Code @model…
Ahmad Bin Shafaat
  • 115
  • 1
  • 4
  • 15
0
votes
0 answers

null parameter in url

I have some javascript that calls an action method on a controller (MVC, C#) there are two parameters defined, both have values but I get a null reference exception. Heres the javascript that calls the action…
proteus
  • 545
  • 2
  • 12
  • 36
0
votes
1 answer

Fire OnActionExecuted even if response is returned from OnActionExecuting

I have following ActionFilter attributes implemented for web apis: LogRequest: This logs the request and response in OnActionExecuted method. ValidateModel: This validates the model and returns BadRequest by setting Response in OnActionExecuting`…
0
votes
1 answer

Inside c:foreach set transient field of a JPA entity and retrieve it

I'm new to JSF. I have a c:foreach element that gets an images list from a bean. Each images list element is an Image object (created by me) that has a transient boolean field. This field initially is false. I also have an outputText to show the…
Euleo
  • 1
  • 3
0
votes
0 answers

ASP.NET Core 2 Controller's ActionMethod async Task returns HttpresponseMessage

UPDATE: As I mentioned I changed my action method, no success. See screenshots The result is the same, no matter: Briefly summarising my problem: Everything is in dot net core 2.0. I have a WebAPI (separate project) and its Controller (talking to…
0
votes
1 answer

void ActionMethod call using ajax post request with verificationtoken overwrites page, turning it blank. How come?

I am trying to call an action method without affecting the view. I call the following action method [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public void Index(LoginModel login)//, string returnUrl) { if (ModelState.IsValid && …
Daniel N
  • 53
  • 1
  • 11
0
votes
0 answers

How to abuse user login with asp.net mvc

I want to abuse a user login. I have two sales agents: name: SalesAgent123 name: HansAlbert the first time I login as SalesAgent123 with a username and password. Then with SalesAgent123 still logged in. I want to login as HansAlbert but this time…
mightycode Newton
  • 3,229
  • 3
  • 28
  • 54
0
votes
2 answers

ajax post not trapping errors, always trapping success

I have an ajax post method to ad new records to a database, the process itself works ok and my server side code traps errors (duplicate input, etc). When an eror happens, the ajax method doesnt 'see' it, the 'success' function is always called. …
0
votes
1 answer

Use single post action method for multiple views

I have an sms sms application, which has different templates that users can use to send their SMSs, I used different view to represent different templates, however I want to use one action method to send an SMS, i might be different templates but at…
Mronzer
  • 399
  • 1
  • 7
  • 18
0
votes
0 answers

How to pass data in $.post jquery to MVC Action method

I am trying to pass data to my controller action Method by using JQuery .$Post method. I have tried multiple ways to pass data but wasn't able to receive any data from the ajax $.post() method. Here is my script $.post("/Home/ListChild/", {"259"},…
hyeo151
  • 1
  • 1
1 2 3
8 9