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
0 answers

Postback for the second time from asp.net MVC view

Setup: I am working on reset password page and planning to have a single view to display three forms one after another. Initially user will be asked to enter username, then the form gets submitted. I am able to capture it is HttpPost action…
RandomUser
  • 1,843
  • 8
  • 33
  • 65
0
votes
0 answers

Nunit testing with action based method fails

In my project we have created action based method like below...which work as expected in our project. public async Task MyMethod(Action SuccessAction, Action ErrorAction) { try { …
aamankhaan
  • 491
  • 1
  • 9
  • 35
0
votes
1 answer

ASP.NET MVC URL Routing problem

i have defined a route as below: context.MapRoute("SearchEngineWebSearch", "search/web/{query}/{index}/{size}", new { controller = "search", …
Sadegh
  • 4,181
  • 9
  • 45
  • 78
0
votes
2 answers

Assign a Viewbag from an @HTML.Action request

I am firing a DevExpress Gridivew when a page is requested @Html.Action("ActionName") Inside this Actionesult method, the code populates the gridview and I would like to use a viewbag to show the total number of items inside the grid. // we have…
user3428422
  • 4,300
  • 12
  • 55
  • 119
0
votes
2 answers

How can i call a Func arguments in a method in C#?

I am trying to create a method which accepts different methods(Funcs) as a parameter. I have a small problem in defining the Funcs arguments. Suppose i need to call some thing like this : public static void SomeTestMethod(int number,string str) { …
Hossein
  • 24,202
  • 35
  • 119
  • 224
0
votes
0 answers

magento How can I set a url request like this? 'baseurl/frontname/index.php?/param'

I need to make an action method that will receive a parameter in the url, perform a search and return an array. Anyway, that's not the problem. My problem is that I want a url like 'baseurl/frontname/param'. I don't know how to do this. I've already…
0
votes
0 answers

MVC action method with jquery cookie value as parameter

I was wondering is it possible that controllers action method take jquery cookie as param, something like this: First i create a cookie with jquery like this: $.cookie('SomeID', 1); And then in controller i check for this value, something like:…
Exerlol
  • 241
  • 3
  • 14
0
votes
1 answer

Paramete value is null in one action method and non-null in another

I have controller called Documents with three action methods: public ActionResult Save(string returnUrl){ TempData["returnUrl"]=returnUrl; return View(viewName: "Save"); } [HttpPost] public ActionResult Save(string returnUrl){ …
Mikayil Abdullayev
  • 12,117
  • 26
  • 122
  • 206
0
votes
2 answers

Redirect to Index Method having no parameters

Please help me, in my controller I am having 2 action methods with same name called "Index" but with different parameters .. public ActionResult Index() {...} [HttpPost] public ActionResult Index(PickingMobile mi, string…
0
votes
2 answers

HttpPost action method recalled when the view presented by it is reloaded

I have an HTTPPOST action method that receives a model and saves it to the database: [HttpPost] public ActionResult AddDocument(Document doc){ DocumentRepository repo= GetDocumentRepository(); repo.SaveDocument(doc); return View(viewName:…
Mikayil Abdullayev
  • 12,117
  • 26
  • 122
  • 206
0
votes
1 answer

IHttpActionResult variable passing null in test method

I am writing a test method for an IHttpActionresult controller. The ActionResult is not NULL and contains the required data (Customer.ID = 986574123). However in line two the variable CreatedResult is null. I want it to return the appropriate data…
user3754602
  • 129
  • 1
  • 2
  • 7
0
votes
2 answers

How to save doctrine database schema in a Symfony controller?

I'm using Symfony 2.3 and Doctrine 2 and i need that an user save the schema of a Doctrine Database to a file (*.sql). I need it into an action method and then send the file to the user
Oscar Acevedo
  • 1,144
  • 1
  • 12
  • 19
0
votes
2 answers

Post to an action which returns a partial view in the original page : MVC

I'm working on a single page web app. The page has a dropdown list. When an item is selected, I use jQuery to post the selected value to an action method, which [for now, for testing purposes] adds that value to the ViewBag, and returns a…
Chris V.
  • 1,123
  • 5
  • 22
  • 50
0
votes
1 answer

How are action methods called when no name is specified

In my LoginController I have the following action method: [HttpPost] public ActionResult Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { if (authProvider.Authenticate(model.UserName, model.Password)) { …
Mikayil Abdullayev
  • 12,117
  • 26
  • 122
  • 206
0
votes
1 answer

asp.net Post a form with view model to controller action method

I have a Fairly Complex Form that I need to post to my MVC controller. Here is the View model which I initially pass to the view on creation: public class EditViewModel { public Service service { get; set; } public bool sms { get; set; } …
Zapnologica
  • 22,170
  • 44
  • 158
  • 253
1 2 3
8
9