Questions tagged [actionresult]

The value returned by the Struts 2 Action class method when it completes.

The value returned by the Struts 2 Action class method when it completes. Actually, it returns a String type value. The value of the String is used to select a result element of the configuration. An action configuration will often have a set of result configurations representing different possible outcomes. A standard set of result tokens are defined by the Action interface are:

String SUCCESS = "success";
String NONE    = "none";
String ERROR   = "error";
String INPUT   = "input";
String LOGIN   = "login";

Further details are available: http://struts.apache.org/release/2.3.x/docs/result-configuration.html

457 questions
697
votes
7 answers

In MVC, how do I return a string result?

In my AJAX call, I want to return a string value back to the calling page. Should I use ActionResult or just return a string?
user67033
  • 15,945
  • 6
  • 21
  • 11
58
votes
6 answers

Must ASP.NET MVC Controller Methods Return ActionResult?

Being new to ASP.NET MVC, I've been wondering about the signature of Controller methods. In all the examples I've seen, they always seem to return ActionResult, even if they actually return a ViewResult instance or similar. Here's a commonly seen…
Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
56
votes
4 answers

How to return an XML string as an action result in MVC

Possible Duplicate: What is the best way to return XML from a controller's action in ASP.NET MVC? I'm able to return JSON and partial views (html) as a valid ActionResult, but how would one return an XML string?
Toran Billups
  • 27,111
  • 40
  • 155
  • 268
51
votes
9 answers

Disable Session state per-request in ASP.Net MVC

I am creating an ActionResult in ASP.Net MVC to serve images. With Session state enabled, IIS will only handle one request at a time from the same user. (This is true not just in MVC.) Therefore, on a page with multiple images calling back to this…
Matt Sherman
  • 8,298
  • 4
  • 37
  • 57
42
votes
5 answers

return error message with actionResult

MVC App, client makes request to server, error happens, want to send the msg back to the client. Tried HttpStatusCodeResult but just returns a 404 with no message, I need the details of the error sent back to the client. public ActionResult…
John
  • 3,965
  • 21
  • 77
  • 163
40
votes
6 answers

How to serve html file from another directory as ActionResult

I have a specialised case where I wish to serve a straight html file from a Controller Action. I want to serve it from a different folder other than the Views folder. The file is located in Solution\Html\index.htm And I want to serve it from a…
Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228
29
votes
1 answer

Returning Empty ActionResult

I may encounter situations, when I need to just return bad request result. For example, there is a call to MVC 3 site's controllers action, but the required parameter is missing in a request uri. What do I return in response. I know I can do…
Maxim V. Pavlov
  • 10,303
  • 17
  • 74
  • 174
29
votes
2 answers

ActionResult> has to return a List

Take the following code using ASP.NET Core 2.1: [HttpGet("/unresolved")] public async Task>> GetUnresolvedIdentities() { var results = await…
Stuart
  • 3,949
  • 7
  • 29
  • 58
28
votes
3 answers

Get a Value from ActionResult in a ASP.Net Core API Method
I try to get a value from ActionResult in an ASP.NET Core API method. The API has a different controller. I try to use a method from controller B in controller A to return the result value. I get an ActionResult object from controller B. I…
Localbug
  • 313
  • 1
  • 3
  • 7
21
votes
3 answers

return new RedirectResult() vs return Redirect()

What is the difference between the following two controller ActionResult return statements: return new RedirectResult("http://www.google.com", false); and return Redirect("http://www.google.com");
Curtis
  • 101,612
  • 66
  • 270
  • 352
20
votes
4 answers

Recommended way to create an ActionResult with a file extension

I need to create an ActionResult in an ASP.NET MVC application which has a .csv filetype. I will provide a 'do not call' email list to my marketing partners and i want it to have a .csv extension in the filetype. Then it'll automatically open in…
Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689
20
votes
2 answers

What are all the available ActionResults for ASP.NET MVC?

What are all the methods that return an ActionResult in ASP.NET MVC as of right now (ie. RedirectToAction, etc.) I haven't found a good documentation resource that lists this kind of stuff.
KingNestor
  • 65,976
  • 51
  • 121
  • 152
18
votes
3 answers

How to unit test an ActionResult that returns a ContentResult?

I want to unit test the following ASP.NET MVC controller Index action. What do I replace the actual parameter in the assert below (stubbed with ?). using System.Web.Mvc; namespace MvcApplication1.Controllers { public class StatusController :…
Nicholas Murray
  • 13,305
  • 14
  • 65
  • 84
16
votes
1 answer

Custom ActionResult equivalent Model for all PartialViews

I created following custom ActionResult which returns multiple partial views. public class MultiplePartialViewsResult : ActionResult { private const string Separator = "-"; private PartialViewResult[] _partialViews; public…
Maximus
  • 3,458
  • 3
  • 16
  • 27
15
votes
3 answers

What's the point of ActionResult return type?

What is the point of an action returning ActionResult?
MVCNewbzter
1
2 3
30 31