POST & GET Behaviour

G

Guest

I created a sample aspx page with a server side Button Control. OnClick event of Button streams an excel file to the client via the following code..
response.Buffer =true
response.Charset = ""
response.ContentType = "application/vnd.ms-excel";
response.AppendHeader("Content-Disposition", "attachment;filename=sample.xls")
response.Write(data)

If the above page is accessed and button is clicked, IE browser throws up TWO Open/Save Dialog boxes.

If i change the "form" attribute "method" to "GET" instead of "POST", IE browser prompts the user with only ONE Open/Save Dialog box. However i like to have the form to have POST mechanism rather than GET and at the same time want the browser to prompt the user only once with Open/Save Dialog box... Any ideas

Thank
Krishn
 
E

Eric Lawrence [MSFT]

Do you have a public url which exhibits this? I'd like to take a look.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

Krishna said:
I created a sample aspx page with a server side Button Control. OnClick
event of Button streams an excel file to the client via the following
code...
response.Buffer =true;
response.Charset = "";
response.ContentType = "application/vnd.ms-excel";
response.AppendHeader("Content-Disposition", "attachment;filename=sample.xls");
response.Write(data);

If the above page is accessed and button is clicked, IE browser throws up TWO Open/Save Dialog boxes.

If i change the "form" attribute "method" to "GET" instead of "POST", IE
browser prompts the user with only ONE Open/Save Dialog box. However i like
to have the form to have POST mechanism rather than GET and at the same time
want the browser to prompt the user only once with Open/Save Dialog box...
Any ideas?
 
G

Guest

Hi Eric
Thanks for your time.Unfortunately this is not in public domain. But i can provide test file (one aspx page with a server side button & aspx.cs class with event procedure for Button control)

SamplePage.asp
--------------------
<%@ Page language="c#" Codebehind="SamplePage.aspx.cs" AutoEventWireup="false" Inherits="SampleReport.SamplePage" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML><HEAD><title>SamplePage</title><meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"><meta name="CODE_LANGUAGE" Content="C#"><meta name="vs_defaultClientScript" content="JavaScript"><meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"></HEAD><body MS_POSITIONING="GridLayout"><form id="Form1" method="get" runat="server"><asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server
Text="Button"></asp:Button></form></body></HTML


SamplePage.aspx.c
-----------------------
using System
using System.Collections
using System.ComponentModel
using System.Data
using System.Drawing
using System.Web
using System.Web.SessionState
using System.Web.UI
using System.Web.UI.WebControls
using System.Web.UI.HtmlControls

namespace SampleRepor

/// <summary
/// Summary description for SamplePage
/// </summary
public class SamplePage : System.Web.UI.Pag

protected System.Web.UI.WebControls.Button Button1

private void Page_Load(object sender, System.EventArgs e

// Put user code to initialize the page her


#region Web Form Designer generated cod
override protected void OnInit(EventArgs e

/
// CODEGEN: This call is required by the ASP.NET Web Form Designer
/
InitializeComponent()
base.OnInit(e)


/// <summary
/// Required method for Designer support - do not modif
/// the contents of this method with the code editor
/// </summary
private void InitializeComponent(
{
this.Button1.Click += new System.EventHandler(this.Button1_Click)
this.Load += new System.EventHandler(this.Page_Load)


#endregio

private void Button1_Click(object sender, System.EventArgs e

Response.Buffer =true
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment;filename=sample.xls")
Response.Write("<table><tr><td>a</td><td>a</td></tr>")
Response.End()


}
 
G

Guest

SamplePage.aspx provided in previous post has <method> attribute of form set to "GET". The problem occurs when the attribute is "POST"

Thank
Krishna
 
E

Eric Lawrence [MSFT]

Parser Error Message: Could not load type 'SampleReport.SamplePage'.

-E

Krishna said:
SamplePage.aspx provided in previous post has <method> attribute of form
set to "GET". The problem occurs when the attribute is "POST".
 
G

Guest

Well, I am sorry for not mentioning about the "namespace". "SampleReport" is the namespace. You can do global replace of "SampleReport" with what ur namespace you have created. Let me know if u still face problem

Thank
Krishna
 
E

Eric Lawrence [MSFT]

I simply copied and pasted your text into two files and hit the ASPX page.
(This copy/paste preserved the namespace declarations in the .CS file, so
I'm not sure what else to change.)

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

Krishna said:
Well, I am sorry for not mentioning about the "namespace". "SampleReport"
is the namespace. You can do global replace of "SampleReport" with what ur
namespace you have created. Let me know if u still face problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top