actionresult

How to get ContentType for file in ASP.NET MVC when using File Action Method

我的未来我决定 提交于 2019-12-02 12:20:34
问题 Attempting to use asp.net mvc's Action Result of File. So it would seem that I have to specify a ContentType for the file to be sent to the browser. Currently there is no real limit to what types of files may be sent to the browser in my application, so I can't always assume it will be a "text/pdf", for example. What's the best way of working out the ContentType of a file, or is there a way where this can be set to something 'generic'? The simpler the better! Thanks, 回答1: You either user the

Using more than one result type in the same action method in struts 2?

烂漫一生 提交于 2019-12-02 10:22:20
问题 I have used the result type stream in my action method which depends on an ajax call. This ajax call is activated on focus out of a textfield on my JSP. The function of this AJAX call is to display an error if the data entered by the user is already present in the backend server. Basically, the server returns a status code that specifies the outcome of the business logic i.e. in my case if my server returns 1016, the data is already present in the server and thus I display an error. However,

Getting JSON object from Java in Struts 2

时光毁灭记忆、已成空白 提交于 2019-12-02 04:29:57
I am trying to get response text from java server using getJSON jQuery method. Although, I can get response data when the java class is simple format ( String , List and Map ), I could not get success data when using other java object. the following Java class is simple type and get access success data and work package com.awitd.framework.action; import com.opensymphony.xwork2.Action; public class getAllJson implements Action{ private String data; public String getData() { return data; } public void setData(String data) { this.data = data; } public String execute() { System.out.println(" this

How to get ContentType for file in ASP.NET MVC when using File Action Method

丶灬走出姿态 提交于 2019-12-02 04:21:27
Attempting to use asp.net mvc's Action Result of File. So it would seem that I have to specify a ContentType for the file to be sent to the browser. Currently there is no real limit to what types of files may be sent to the browser in my application, so I can't always assume it will be a "text/pdf", for example. What's the best way of working out the ContentType of a file, or is there a way where this can be set to something 'generic'? The simpler the better! Thanks, Bryan You either user the local machine's database of MIME types (from the registery): http://www.codeproject.com/KB/dotnet

Calling httppost actionresult from inside a view using a button

馋奶兔 提交于 2019-12-02 03:16:42
I have a project to make an online shop between users (post a product, buy, etc.) using a database. In this project I have a view called "ShoppingCart": @model IEnumerable<MyFirstProject.Models.Product> @{ ViewBag.Title = "ShoppingCart"; Layout = "~/Views/Shared/_Layout.cshtml"; } <h2>Your Shopping Cart</h2> @if (Model == null) { <div style="float:left">Your cart is empty.</div> <div> Total payment: 0 </div> } else { decimal tPrice = 0; <div> <table style="float:left"> @foreach (var product in Model) { tPrice = tPrice + product.Price; { Html.RenderPartial("ProductLine", product);} } </table> <

I want to download a pdf file which is stored in the folder which is in WebContent of project

醉酒当歌 提交于 2019-12-02 01:45:48
问题 This is my Strut file. <action name="sample" class="com.action.getPdf" method="getPdf"> <result name="success" type="stream"> <param name="inputName">fileInputStream</param> <param name="contentType">application/pdf</param> <param name="contentDisposition">attachment;filename="${fileName}"</param> <param name="bufferSize">1024</param> </result> </action> and this is action code where the object of File is getting null . public String getPdf()throws Exception { Session ss = HibernateUtils

Download file from ajax and ActionResult

本小妞迷上赌 提交于 2019-12-01 22:50:15
I want to download files on browser with ajax and ActionResult. The file is downloaded and returned from my ActionResult. I see the Http query is ok and see the data in the response body. The problem is that the file is not proposed to save in the browser. All seems good. All that I seen in tutorial and forum were like I done but mine don't word XD. I don't understand what is the difference between mine and the others. Here is my ActionResult : public ActionResult ShippingDownloadDNPriority(string SALE_GUID) { int supId = -1; int.TryParse(Session["SupId"].ToString(), out supId); if (supId < 0)

Regarding the Action Mapping in Struts2 - There is no Action mapped

烈酒焚心 提交于 2019-12-01 12:32:39
问题 I am trying to run my struts application but I am getting a error action is not mapped I have seen the namespace it is correct but still getting the error? struts.xml : <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="false" /> <include file=

No result defined for action and result

China☆狼群 提交于 2019-12-01 11:04:06
Default result is not rendering using result for my package alone. Flow goes to my n0result method then It throws Exception . Please correct my wrong configuration. Output : Hello How are you noresult() method got called..... Dec 26, 2013 12:48:04 PM org.apache.struts2.dispatcher.Dispatcher serviceAction SEVERE: Could not find action or result No result defined for action leo.struts.HelloWorldAction and result noresult - action - file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Strut2Examples/WEB-INF/classes/struts.xml:99:93 at com.opensymphony.xwork2

All inbuilt ActionResults in ASP.NET MVC

核能气质少年 提交于 2019-12-01 08:54:40
I'm looking for a list of the inbuilt (and 3rd party would be a bonus) ActionResults you have available to you in a controller in ASP.NET MVC. So far I've discovered the following: ContentResult - this.Content() ActionResult - this.View() JsonResult - this.Json() JavascriptResult - this.Javascript() PartialViewResult - this.PartialView() Have I missed any useful ones that are out there? From this source : ContentResult Writes a string value directly into the HTTP response. EmptyResult Does not write to the HTTP response. FileContentResult Takes the contents of a file (represented as an array