Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9156193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:43:33+00:00 2026-06-17T12:43:33+00:00

I am coming from razor in asp.net. Usually I would use a [FilePost] for

  • 0

I am coming from razor in asp.net. Usually I would use a [FilePost] for this, but not sure how to do it in grails. Here is the situation

I have a controller

class MyController{
def index{ }
}

I then have a link on index in the form of

<g:link controller="MyController" action="downloadFile">Download</g:link><br>

What I want this to do is take a string (doesn’t matter what it is) and I want it to prompt the user to download a text file containing that string. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:43:34+00:00Added an answer on June 17, 2026 at 12:43 pm

    Working Solution:

    def downloadFile =
    {
        File file = File.createTempFile("temp",".txt")
        file.write("hello world!")
        response.setHeader "Content-disposition", "attachment; filename=${file.name}.txt"
        response.contentType = 'text-plain'
        response.outputStream << file.text
        response.outputStream.flush()
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coming from a .NET background I'm use to reusing string variables for storage, so
Coming from ASP.NET into WindowsForms app development I was expecting to see the similar
I have an ASP.NET MVC 3 view using Razor and Knockout.js that is not
Coming from a desktop background I'm not sure exactly how to pass the exceptions
I am coming from a ASP.Net MVC world where Microsoft provides the LinkExtensions.ActionLink method
Coming from the MS SQL world, I tend to make heavy use of stored
Coming from a scripting background, I've started working with c# and .net. I've created
Coming from a background in Django, I often use template inheritance, where multiple templates
I am using Asp.NET MVC4 with Razor. I want to show a list of
Coming from an Classic ASP background I'm pretty cautious about placing objects into Session.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.