actionresult

Struts 2.3 - redirect vs redirectAction

北城余情 提交于 2019-12-19 08:12:54
问题 What is the main difference between redirect and redirectAction in Struts2.3 context. I have seen below URLs for redirect and redirectAction. I am clear about below points: redirect is like sendRedirect() method. New request is created which clear the previous value stack and action (action instance, action errors, field errors, etc) no longer available. In redirectAction , control jumps to the different action(in same or other package) redirectAction is recommended over redirect. But when I

ActionResult<IEnumerable<T>> has to return a List<T>

狂风中的少年 提交于 2019-12-18 12:55:22
问题 Take the following code using ASP.NET Core 2.1: [HttpGet("/unresolved")] public async Task<ActionResult<IEnumerable<UnresolvedIdentity>>> GetUnresolvedIdentities() { var results = await _identities.GetUnresolvedIdentities().ConfigureAwait(false); return results.ToList(); } I would have thought since GetUnresolvedIdentities() returns IEnumerable<UnresolvedIdentity> that I could just return return await _identities.GetUnresolvedIdentities().ConfigureAwait(false); Except I can't, as I get this

return new RedirectResult() vs return Redirect()

邮差的信 提交于 2019-12-18 12:50:01
问题 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"); 回答1: straight from the source // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. using System.Diagnostics.CodeAnalysis; using System.Web.Mvc.Properties; namespace System.Web.Mvc { // represents a result that performs a

Recommended way to create an ActionResult with a file extension

杀马特。学长 韩版系。学妹 提交于 2019-12-18 10:41:45
问题 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 Excel. http://www.example.com/mailinglist/donotemaillist.csv?password=12334 I have successfully done this as follows, but I want to make sure this is the absolute best and recommended way of doing this. [ActionName("DoNotEmailList.csv")] public

Using ActionForward with dynamic params in Struts 2

人盡茶涼 提交于 2019-12-17 20:24:56
问题 While migrating the application from Struts 1 to Struts 2 In some of the places, the same action class has been used for different type of views, based on the request params. For Example: if the createType is 1 means need to append one param or if the createType is 2 means need to append some more extra params, like that I need to pass dynamic params to some other action using ActionForward . struts-config.xml <action path="/CommonAction" type="com.example.CommonAction" scope="request">

Disable Session state per-request in ASP.Net MVC

半世苍凉 提交于 2019-12-17 02:59:07
问题 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 Action, only one image request can be handled at a time. It's synchronous. I'd like this image Action to be asynchronous -- I'd like multiple image requests to each execute without needing the previous one to complete. (If the images were just

In MVC, how do I return a string result?

穿精又带淫゛_ 提交于 2019-12-17 02:53:12
问题 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? 回答1: You can just use the ContentResult to return a plain string: public ActionResult Temp() { return Content("Hi there!"); } ContentResult by default returns a text/plain as its contentType. This is overloadable so you can also do: return Content("<xml>This is poorly formatted xml.</xml>", "text/xml"); 回答2: You can also just return string if you know that's the only

PartialView cumulatively adding issue

北城以北 提交于 2019-12-13 18:12:31
问题 I want to make a modular web site.Everything is going well but i have encountered a problem when cumulatively added module.I want to load content dynamically as below: For contact page: Content.cshtml : Lorem ipsum dolor Contact.cshtml Content.cshtml : Adress : Tbilisi/Georgia But load only first content rightly as below Content.cshtml : Lorem ipsum dolor Contact.cshtml Content.cshtml : Lorem ipsum dolor How can i solve this problem? tblModule +---------+-------------------------+ | ModulId |

Does the Controller's HttpPost ActionResult get called at the start of, during, or after the form's submit event?

眉间皱痕 提交于 2019-12-13 07:06:55
问题 This is a followup to my question here: Why are my "replacement parameters" getting transformed into empty strings? Okay, maybe somebody can help me understand what's going on here (note that I didn't write this code, so I'm approaching it from the perspective of a problem bear that has just been heli-dropped into unfamiliar terrain). As it seemed more natural/conventional to do so, I changed my handler from a submit button click handler to the form's submit handler: $("form").submit(function

Why is my AJAXoned Action's return not being seen as successful by the caller?

喜夏-厌秋 提交于 2019-12-12 05:59:51
问题 In my ASP.NET MVC app, I've got this AJAX call in my View's script section: $(".ckbx").change(function () { . . . $.ajax({ type: 'GET', url: '@Url.Action("GetUnitReportPairVals", "Home")', data: { unit: unitval, report: rptval }, cache: false, success: function (result) { alert(result); } }); }); Stepping through the Controller action being called: public ActionResult GetUnitReportPairVals(string unit, string report) { HomeModel model = new HomeModel(); int rptId = GetReportIDForName(report);