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
2
votes
3 answers

ajax call results in error instead of succes

In my ASP.net mvc3 project, i use a ajax call to send json data to a create actionmethod in the controller Company. But when i debug the ajax call, it always end up in a error result instead of the succes result. ajax call: $.ajax({ …
Thomas
  • 297
  • 1
  • 8
  • 21
2
votes
1 answer

Ambiguous action methods in MVC 2

I'm having some problems with ambiguous action methods in MVC 2. I've tried implementing the solution found here: ASP.NET MVC ambiguous action methods, but that simply gives me a "The resource cannot be found" error as it thinks I'm trying to…
Major Productions
  • 5,914
  • 13
  • 70
  • 149
2
votes
1 answer

dot net core custom model binding for generic type parameters in mvc action methods

I am building a simple search, sort, page feature. I have attached the code below. Below are the usecases: My goal is to pass the "current filters" via each request to persist them particularly while sorting and paging. Instead of polluting my…
2
votes
0 answers

Having logic of selecting action and controller in processrequest

I have a processrequest method in custom mvc handler. I like to render specific action based on requestcontext. following is my code public void ProcessRequest(HttpContext context) { if(Request.QueryString["lid"]!=null && ...){ …
user786
  • 3,902
  • 4
  • 40
  • 72
2
votes
2 answers

How do you set the Database details on Sitecore.Context.Item.Database item in Sitecore

I am currently reviewing an existing Sitecore project. One of the items has a controller rendering that outputs a form onto the Layout. In the Action Method, for the controller rendering, there is a line that seems to get the Item's Database Name…
hoChay
  • 37
  • 10
2
votes
1 answer

ASP.NET MVC - Optionally Redirect from a Base Class Method?

Consider the following block of code that reappears in many of my controller actions. (I'm chiefly concerned with the first 6 lines of the method body). [HttpGet] public ActionResult OptOut() { var user = this.SecurityPrincipal; if…
Mike Hofer
  • 16,477
  • 11
  • 74
  • 110
2
votes
3 answers

Default value for parameter in Controller Method is overriding everything

Hello i have just started learning mvc2 and im having a problem with the default value for the parameter page(you can see the method below). Its always 0 regardless of what i type in the URL. For example…
Kimpo
  • 5,835
  • 4
  • 26
  • 30
2
votes
4 answers

Multiple clicks on UIButton trigger Target function multiple times

I have a UIButton. I bound a target as follows. [button addTarget:self action:@selector(myFunction) forControlEvents:UIControlEventTouchUpInside]; When i click my Button multiple times quickly it invoke the target function multiple…
waseemwk
  • 1,499
  • 3
  • 15
  • 44
2
votes
1 answer

How to attach a description to each ActionMethod in a Controller (ASP.net MVC)?

So recently, I came up with a way to dynamically build a nav-bar menu where the Controller (And its Index ActionMethod) would be listed in a horizontal bar at the top of each page (via Site.Master) but also based on the user's assigned roles. Each…
Pretzel
  • 8,141
  • 16
  • 59
  • 84
2
votes
3 answers

How can i pass two different query string params that represent one action method param?

i've got an action method like the following public JsonResult Index(string version) { .. do stuff, return some data v1 or v2. Default = v2. } So, this action method returns some data, which can be formatted either as Version 1 or Version 2…
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
2
votes
2 answers

How to fire mailto urls from action method

I am a beginner in MVC. I want to develop an action method in MVC which fires Mailto:?body=body goes here.&subject=test subject and so the default mail client will automatically populate the email for the user. Right now I have List which…
Suraj
  • 345
  • 1
  • 2
  • 12
1
vote
1 answer

pass input type image name/value as a parameter to Action Method in MVC 3

I have an image in a view Now what I need to do is to pass the name of the image ("Next") to the action method in the controller, when a user clicks the image...which causes a Post…
NiK
  • 1,827
  • 1
  • 20
  • 37
1
vote
3 answers

ASP.NET MVC3 : ActionMethod with same name and different arguments for List and Details view

I have a ProdcutsController where i have 2 Action methods. Index and Details. Index will return list of products and Details will return details of a selected product id. So my urls are like sitename/Products/ will load index view to show a list…
Happy
  • 1,767
  • 6
  • 22
  • 26
1
vote
2 answers

ASP.Net MVC Routing with HTTP Action Verbs

I am writing a implementing a ASP.NET web app, and when I call against a particular url, I want to call a different action method depending on whether the request is a GET or a POST. I've tried two different approaches - first of all I start with a…
Martin Milan
  • 6,346
  • 2
  • 32
  • 44
1
vote
1 answer

What is the "best" way to handle alternately Post and Get Actions?

I am trying to build sth pretty simple, but I try to do it the correct way. But I struggle to figure out what is best. I have a process chain where the user has to fill in some fields in different forms. Sometimes it depends from the user inputs…
misanthrop
  • 771
  • 7
  • 32
1 2
3
8 9