How to set the filename when downloading a file?

I'm working on mvc4. I have generated excel file dynamically using following simple code my hosting is on Azure
I have created a Root path and then try to save that excel file.
Problem is when my Action Result method response comes back it is giving default popup to open a file but file name is having a GUID instead my provided file name
What id wrong any clue?
Excel file generation code:
Microsoft.Office.Interop.Excel.Application xlApp =
new Microsoft.Office.Interop.Excel.Application();
return tempPath;
This method returns something like C:\AppData\Local\dftmp\Resources\11a2435c-998c-4fe8-aa55-8bb42455b4ca\directory\myexcelFILE.xls.
The Download File popup does not give file name as myexcelFILE.xls it gives some GUID why so?
Action
Result method code
public ActionResult DownloadExcel(){
string path = ExcelGenerationCode(fileName);
Stream s = new FileStream(path, FileMode.Open, FileAccess.Read);
return new FileStreamResult(s, "application/vnd.ms-excel");
Ashish Fugat (ashuthinksatgmail.com) SE

http://forums.asp.net/
The above forum has the MVC section.

Similar Messages

  • How to get the filename when parsing a file with d3l

    All
    After some time have experience with interconnect, IStudio I need the following info. Is it possible to get the filename when parsing a flat file using a d3l? This is needed because we need to store the filename together with the data into the database.
    Any examples or directions to some documents are welcome.
    Regards
    Olivier De Groef

    has anyone some info on this

  • How to set the selectedIndex when dataProvider is an XML object in DropDownList?

    dataProvider was an XML object
    How to set the selectedIndex when dataProvider is an XML object in DropDownList?
    I do this:
    <s:DropDownList id="dropDownList" requireSelection="true" selectedIndex="2"
                    labelField="lastName" dataProvider="{employeeService.lastResult.employees.employee}"/>
    But always the first item is selected whatever the value of selectedIndex equals to.

    if i understand correctly, you want the selectedindex to be 2 when the DropDownList  displays.
    It might be the case that the dataprovider is being sought after it's already selected its index (as the dataprovider isn't already determined to begin with), so currently it's
         - setting the selected index to default
         - setting the selected index to 2 (your command)
         - getting the dataprovider
         - setting the selected index to default
    try writing a function to set the DropDownList's selected index after it's received the information, or even just attach it to the employeeService result handler.
    for quick testing sake you could just add
    <s:DropDownList id="dropDownList" requireSelection="true" updateComplete="dropDownList.selectedIndex = 2"
                    labelField="lastName" dataProvider="{employeeService.lastResult.employees.employee}"/>
    to see if my theory is correct.

  • How should i set the baseURI when a db file path with a space

    if the db file in a path like c:\program file\myapplication,then i set the baseURI dbxml:c:\program file\myapplication ,some exception occur~what should i do ?
    thanks a lot

    The Base URI needs to be a valid URI, which means it cannot include the Windows '\' character at all. In your case, you should be fine using something along the lines of "file:////C:/program file/myapplication"
    (give or take a '/' or two -- I haven't tested this).
    It's a common for BDB XML users to confuse the argument to create/openContainer() (a filesystem path) with the Base URI (a URI). The meanings and requirements are different. The best thing to do is to set and use a container alias (XmlContainer::addAlias()) to use in your queries.
    Regards,
    George

  • How to set the classpath for external .jar files after importing?

    Hi techs,
    How to set the classpath in WSAD5.1.2 after importing the .jar file to the WEB-INF/lib folder.
    urgent

    I got it.
    after importing the jar file to the perspective,we need to right click on project name, go to proprties,
    goto java build path,
    there we need to include the external jar files.

  • FtpAdapter How to set the filename

    Hi,
    I am using FtpAdapter to put files I want to set the custom filename how do I do that. I am storing a filename in a variable and needs to have that name when FtpAdapter puts the file on a Ftp Server.
    Thanks

    Well to dynamically assign file name to the FTP'ed file, need to use the ftpAdapterOutboundHeader.wsdl
    Create a variable of OutboundHeader_msg message type which is defined in ftpAdapterOutboundHeader.wsdl
    Assign the custom file name to this newly created variable's fileName element.
    For example if Variable_File_Name_Obj is the variable created then the code should include
    Variable declaration
    <variable name="Variable_File_Name_Obj"
    messageType="namespace:OutboundHeader_msg"/>
    Assign
    <assign name="Assign_File_Name">
    <copy>
    <from some variable>
    <to variable="Variable_File_Name_Obj"
    part="outboundHeader"
    query="/namespace:OutboundFTPHeaderType/namespace:fileName"/>
    </copy>
    </assign>
    Kalidass
    http://oraclebpelindepth.blogspot.com/

  • How do I get a "Details" display--as the default--when downloading a file, in the "Enter name of file to save to..." dialog box?

    When I receive an attachment to an email, and I click it and select "Download", I get the "Enter name of file to save to..." dialog box (because I already set the option to "Always ask me where to save files." But the file display always defaults to a "List". At least recently. I don't recall it always doing that. In any case, I want it to default to a "Details" display, in ascending order, as I can then find things sooo much faster that way. (I often use the "Date Modified" tab to bring to the top the most recent version of a file.) I know that I can go to the "View Menu" icon and select "Details", but each time I go into a sub folder while in this dialog box, I have to do that all over again and it wastes a lot of time and attention.
    I did some internet searches but didn't find a way to fix this.

    Thanks for reaching out, glennr.
    The dialog box you are describing is controlled by Windows, not Firefox, so unfortunately Firefox cannot change what you see by default.
    I think your best bet would be to ask on the [http://answers.microsoft.com/en-us/windows/forum/windows_xp?auth=1 Windows support site].

  • How to set the status when Idoc fails

    Hai ,
    I created Idoc extension & created a segment under that(Delivery related).
    My requirement is,
    if certain data not found,
    Idoc should fail with text"Shipemnt for delivery <del. No> not found.
    Could you please help me how to do this?
    I checked the table EDIDC table but the above mentioned status is  not there.
    Thanks & Best Regards,
    Bhaskar.

    you need to set the status using IDOC_STATUS
    where ever error occurs populate the status table.
    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
       IDOC_STATUS-STATUS = '51' ." if it is inbound
       IDOC_STATUS-MSGTY  = Message-type.
       IDOC_STATUS-MSGID  = message-id.
       IDOC_STATUS-MSGNO  = message-MSGNR.
       IDOC_STATUS-MSGV1  = message-MSGV1.
       IDOC_STATUS-MSGV2  = message-MSGV2.
       IDOC_STATUS-MSGV3  = message-MSGV3.
       IDOC_STATUS-MSGV4  = message-MSGV4.
    *  IDOC_STATUS-SEGNUM = ?????????????????
    *  IDOC_STATUS-SEGFLD = ?????????????????
    *  IDOC_STATUS-UNAME  = ?????????????????
       IDOC_STATUS-REPID  = SY-REPID
    *  IDOC_STATUS-ROUTID = ?????????????????
       APPEND IDOC_STATUS.

  • Changing filename when downloading generated file

    The scenario:
    There is a list of files that logged in users are able to download. The files themselves are not kept within the web root, as we need to be able to ensure that a user has rights to download the file. To do this I have created a JSP page which (a) checks that the user is logged and has appropriate permissions, (b) sets the content type to something the browser does not understand (to ensure the file, which is basically just text is downloaded instead of just displayed in the browser) and (c) gets and includes the content of the file using java.io.File.
    The problem:
    ... with this approach is that it uses a link which looks something like thefile.snd. This means that the file name in the save dialogue always defaults to 'getfile.jsp', when it needs to default to 'thefile.snd'.
    Any ideas? I've considered using an signed applet to do the download and rename the file but would like to avoid this if possible (although if anyone has the source for such an applet that would also be helpful).

    Thanks for the post clem. FYI, I had a similar problem but my data was coming from a database - not a file on disk. At first, setting the content-disposition wasn't working. Then I removed the "file; " part and left just
    response.setHeader("Content-Disposition","filename="+filename);
    and it worked.

  • How to set the field size in rule file.

    i have to map total 30 fields in a rule file while by default it allows only 20 fields. so how can we set the fields as per our need?

    Hi Dharmendra Ojha,
    Essbase rule file does not constrain you with only 20 fileds.
    When you click on 'create a rule file', by default it ll show you 20 fileds .But , when you open a data file ( in your case , you data file has 30 columns i.e 30 fields) in the data prep editor , you ll see all 30 fileds .
    So ,you have to do nothing to increase the filed count , rule file will automatically show all fields .
    Revert back for further clarity
    Sandeep Reddy Enti
    HCC
    http://analytiks.blogspot.com

  • How to set the name for an 'unknown' file extension?

    Specifics:
    I have various file extensions that are recognized by my mac. I would like to know how to create a list of applications that can open it so I do not get a 'There is no Default Application to open this file' error. I would also like to be able to give these file extensions names recognized by the mac.
    Just like .txt is a "Textedit Document" and .html is a "HTML Document," I'd like to be able to change the name and assosication of a file and give it its own .icns if possible.
    As for the default applications, I know how to set a default application. However, if a mac does not recognize a file extension, adding a new default application to run the file wil actually erase the old one, which is a big pain, especially when your file can be opened with ANY text editor.
    I understand that this may involve hacking into the operating system's databases, but if anyone can help, it would be greatly appreciated.

    Hi Timo,
    My jdev version is 10.1.3.3.0, this is for R12. By PR i mean to say process request and PFR process form request in the controller.
    In the Process request of the controller, i am finding the checkbox bean and assigning the firepartialaction for it.
    Later in the process form request for the fired event, i am trying to handle the rendered property of the messagetextinput. Is this a right approach?
    my code below
    public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    super.processRequest(oapagecontext, oawebbean);
    OAApplicationModule oaapplicationmodule = oapagecontext.getApplicationModule(oawebbean);
    OAMessageCheckBoxBean oamessagecheckboxbean = (OAMessageCheckBoxBean)oawebbean.findChildRecursive("X_FLAG");
    if(oamessagecheckboxbean != null)
    oapagecontext.writeDiagnostics(this, "Message check box Bean found:", 1);
    FirePartialAction firepartialaction = new FirePartialAction("change");
    oamessagecheckboxbean.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR, firepartialaction);
    oamessagecheckboxbean.setFireActionForSubmit("change", null, null, true);
    oapagecontext.writeDiagnostics(this, "setting fire event", 1);
    public void processFormRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    super.processFormRequest(oapagecontext, oawebbean);
    oapagecontext.writeDiagnostics(this, "Inside Process Form Request", 1);
    if("change".equals(oapagecontext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
    OAMessageTextInputBean bean = (OAMessageTextInputBean)oawebbean.findChildRecursive("X_NUMBER");
    if(bean!=null){
    bean.setRendered(Boolean.TRUE);}
    Thanks,
    Malar

  • How to set jpeg resolution when saving pdf file as jpeg

    I'm running Acrobat using interprocess api, I can invoke a script to save a pdf file as JPEG, but I need to be able to set the resolution of the saved jpeg file.
    Any clues as to how I can do that ?
    Peter

    Hi
    I am running a stand-alone version of Framemaket 10.I try to convert a documentation with a lot of screenshots in it. Regardless of the settings on the Reference pages of the first document of the book, Framemaker converts all graphic files to *.gif, and these are downsized so much that they become illegible. I would like to have them converted to JPG, with little resolution loss, so they are still readable.
    I think Robohelp is too expensive…
    Best regards
    REIDEN TECHNIK AG
    Alexander Keller
    Tech Writer

  • How to set the size of an Excel-file,Java created in tabbed forma

    Hi all,
    I'm creating an Excel-file by writing data to an outputStream in tabbed format.
    My problem is : How can I set the width of the columns of that Excel-file, not the default-size?
    If anyone can help, that would be very nice.
    Thanks a lot,
    Regards,
    Tim

    You can write a generic xls file containing a Macro to open and set the column widths of text or csv files. Your java program can then call this generic file to open your text files.

  • How to fix the VMWARE ERROR DOWNLOADING KICKSTART FILE ON Redhat linux 6.0

    Hi Team,
           While deploying RHEL6.0 i am getting error "VMWARE ERROR DOWNLOADING KICKSTART FILE ON Redhat linux 6.0" Please let me know how to fix this issues.
    Thanks
    vmware tech

    theoretically all I need to change would be
    changed it to var handd = new hand();
    change stage.addChild(hand);    to     stage.addChild(handd);
    and the part im unsure on is
       else
                        trace(fl_SecondsCounted + " sec");
                        hand.rotation = hand.rotation + 6;
                        fl_SecondsCounted--;
    do I leave that part or change it to handd.rotation = handd.rotation + 6

  • How to solve the "Enter" when include a file?

    Hello everyone!
    I want to add the following line in JSP:
    <%@ include file="gris.txt" %>
    But the JSP page can't identify the "Enter" key so that it shows the file as a string which is meaningless.
    Who can help me to show it normally?
    And I could show a string including "Enter" symbal normally but on the other hand I don't know how to read a file as a string.
    Anyone could help me?Thanks a lot!
    PS: The data in the file just like a table, and it's better that someone could give me a method to show it as a table.

    When I had a problem like this, I created a Servlet that translated the text to HTML:
    package servlets;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.html.*;
    public class TextDisplayServlet extends HttpServlet
                                                                  throws ServletException, IOException
      public void doGet(HttpServletRequest request, httpServletResponse response)
        String toRead = request.getParameter("file");
        if (null != toRead)
          File file = new File(toRead);
          if (file.exists())
            FileInputStream in = new FileInputStream(file));
            response.setContentType("text/html; charset=UTF-8");
            response.setBufferSize(5120);
            PrintWriter out = response.getWriter();
            //HTML to set title and make text display as written in file (the <pre> tag)
            //Not sure how puttong the <head></head> in here will afect the include...
            out.printl("<html><head><title>"+toRead+"</title></head><body><pre>");
            int ch = -1;
            while ((ch = in.read()) != -1)
              // These line escapes possible HTML tags in your file, so > and < get displayed correctly...
              if ('<' == ch) out.print("<");
              else if ('>' == ch) out.print(">");
              else out.print((char)ch);
            out.close();
            in.close();
    }The web.xml has the following servlet mappings:
      <servlet>
        <servlet-name>File_Servlet</servlet-name>
        <servlet-class>servlets.TextDisplayServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>File_Servlet</servlet-name>
        <url-pattern>/File</url_pattern>
      </servlet-mapping>The I call the servlet like this (as an example)
    /File?file="C:\Full\Path\To\theFile.txt (escape \ to \\ in java string....)
    In the case above, I made it able to read any file in the file system, in exchange I have to use the full path to the file. If you want to limit the ability to read files to the context of your web-app, and as such only have to use relative paths, you could change the way you make your input stream:
       * replace this *
      File file = new File(toRead);
      if (file.exists())
        FileInputStream in = new FileInputStream(file));
       *   with this  *
      InputStream inStream = getServletContext().getResourceAsStream(toRead);
      if (null != inStream)
        InputStreamReader in = new InputStreamReader(inStream);
      }

Maybe you are looking for