|
Hi,
I am new to asp.net although not to c# and I need to put together an aspx page that receives data sent to it via a web form using GET.
I can get the sent data OK but I need to use that data to generate a binary file. I can do that OK as well.
The problem I have is I need to serve that generated file back to the requesting server automajically
Can some one explain how I can do that and if possible provide example code OR better still, point me to a tutorial that covers this without over complicating the issue.
Thanks,
-- modified at 21:57 Friday 18th May, 2007
I think I'm getting there The following code partially solves my problem EXCEPT there are two issues - (1) The file being sent includes the text in the aspx page as well as the text in the file and (2) I need to get rid of the prompt to download the file. Here's the code:
<br />
private void SendKeyFile()<br />
{<br />
string root = "C:\\temp\\";<br />
string filepath = root + "debug.txt";<br />
if (!(filepath == null))<br />
{<br />
if (File.Exists(filepath) && filepath.StartsWith(root))<br />
{<br />
string filename = Path.GetFileName(filepath);<br />
Response.Clear();<br />
Response.ContentType = "application/octet-stream";<br />
Response.AddHeader("Content-Disposition", ("attachment; filename=\"" + (filename + "\"")));<br />
Response.Flush();<br />
Response.WriteFile(filepath);<br />
}<br />
}<br />
}<br />
Am I on the right track here?
Glen Harvy
|
|
|
|
|
You would want to send the file in the response stream. You wouldn't have to send it in the header as an attachment. You can send it in the response stream it self.
If you don't want any aspx page stuff in the response, then you need to remove them from your form. No HTML tags, just the very first line <%@Page ... is all you need.
Hope that helps.
Ben
|
|
|
|
|
Thank you very much for this. You have helped me enourmously
Glen Harvy
|
|
|
|
|
I need to know what components to use in visual studio for creating a FORUM!!! sigh:
|
|
|
|
|
There are no components that magically create one for you, you need to write it yourself.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
*grin* what does that mean ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
No component...you can find some other open source projects ....
<< >>
|
|
|
|
|
Hi All,
Please suggest me any good component, which converts doc to pdf, merge pdf, spilt pdf, barcode generation on pdf file.
I tried on google, i found Dynamic PDF but i am here becuase i want to get benifit from you guys experience.
Many Thanks & Best Regards,
Adnan
Many Thanks,
Adnan Rafiq
muhammadadnanrafiq@gmail.com
|
|
|
|
|
Hi,
Please suggest me any article, how to deploy ASP.Net 2.0 application on LAN or Intranet.
Many Thanks & Best Regards,
Adnan
Many Thanks,
Adnan Rafiq
muhammadadnanrafiq@gmail.com
|
|
|
|
|
Use the publish function under Build menu....
<< >>
|
|
|
|
|
can anyone help me with dll files for example creating email,calendar,etc in asp.net and how to use them in asp.net!
|
|
|
|
|
s_a_200263 wrote: can anyone help me with dll files for example creating email,calendar,etc in asp.net and how to use them in asp.net!
Sorry, I really don't understand what you mean.
To use a DLL file (an class library assembly) add them it as a reference to your project. You'll then be able to access the classes within.
|
|
|
|
|
I have heard for example I can use outlook in my portal through a dll file!!
|
|
|
|
|
You can send emails using classes built into the framework. Outlook can be interoped with C#, but not, I don't believe, as web controls.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Our company is wanting to implement AJAX and it has been my task to get everything up and running. One of the major issues that I have run into is throughout our application we use response.write to use JavaScript files in our basepage. See Example:
Response.Write("")
Response.Write("")
I have been trying for the page few days to use ClientScript.RegisterStartupScript or ClientScript.RegisterClientScriptBlock()but with no luck. My Ajax section is working without the response.write but with them I get the dreaded sys.webforms.pagerequestmanagerparserErrorException error.
Any kind of suggestions will be great.
Thanks,
Cisco2103
|
|
|
|
|
Why is it necessary to write out the script tags? Can't they just be placed on the page directly?
You need to add these to the header section of the page. RegisterClientScript places them in form. You could try overriding the Init or PreInit for the page and inserting them then.
only two letters away from being an asset
|
|
|
|
|
I've tried putting them in the header section of the page but with no luck. Not very familiar with Init and PreInit since I am pretty new to .Net What would I accomplish by doing this?
|
|
|
|
|
cisco2103 wrote: I am pretty new to .Net
Perhaps you should step back do some research first.
only two letters away from being an asset
|
|
|
|
|
I would think asking an asp.net question on a forum devoted to asp.net could be considered a form of research.
|
|
|
|
|
cisco2103 wrote: I've tried putting them in the header section of the page but with no luck.
Just add Literal controls with the script as text, as children to Page.Header .
cisco2103 wrote: Not very familiar with Init and PreInit since I am pretty new to .Net What would I accomplish by doing this?
Nothing, really. It doesn't matter much when you add the controls to the page, as long as it's done before the renderinging, and that only rules out the Unload and Disposed events, AFAIK.
---
single minded; short sighted; long gone;
|
|
|
|
|
Use RegisterClientScriptBlock to add javascript to your page. Better yet, as you're referencing .js files ( which is always better ), just put the code direct into the aspx.
I tend to use registerclientscript block to create variables in my script which give me the names of ASP.NET generated controls, so I can interact with them in my javascript/AJAX code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
The following line
(Convert.ToDecimal(NET.Text) / 117.5 * 100).ToString()
creates the value - 42.55319148 ......
All i wantis 42.55
How do I go about this?
Thank
|
|
|
|
|
ToString("#.00") if you want to restrict and force 2 decimals places
ToString("#.##") if you want to restrict 2 decimals places
ToString("N2") equivalent to ToString("#.00")
|
|
|
|
|
You can use abs for absolute value. abs((Convert.ToDecimal(NET.Text) / 117.5 * 100)).ToString(###,###.##)
|
|
|
|