Saturday, March 24, 2012
Strange error with Response.WriteFile and SSL
page which returns a dynamically created PDF file using Response.WriteFile.
When the browser requests this ASPX page via https (SSL) it displays a
message that secure and non secure items are to be displayed (free
translation from german so it might not be the exact wording in english).
When I say no (means non secure items are not displayed) my PDF still is
displayed - so it seems thats not the one causing the message.
Any ideas whats wrong or even better how to solve it?
Regards,
Martin Knopp
fecher GmbH"Martin Knopp" <martin.knopp@.fecher.at> wrote in news:GGVQb.304173$Tz1.135851
@.news.chello.at:
> I have a site running under SSL. Works well so far but there is one ASPX
> page which returns a dynamically created PDF file using Response.WriteFile.
> When the browser requests this ASPX page via https (SSL) it displays a
> message that secure and non secure items are to be displayed (free
> translation from german so it might not be the exact wording in english).
> When I say no (means non secure items are not displayed) my PDF still is
> displayed - so it seems thats not the one causing the message.
> Any ideas whats wrong or even better how to solve it?
It means that somewhere in the content you are sending back are some http://
referendces instead of https:// references. You need to make all images, and
other external type links https://
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com
That would have been easy!
I checked for this already and the only thing we return is a PDF document.
Nothing else.
Today I heard from some source that it might be a problem of IE. I will have
to further investigate this probably.
Any other ideas/hints?
--
Martin Knopp
fecher GmbH
"Chad Z. Hower aka Kudzu" <cpub@.hower.org> schrieb im Newsbeitrag
news:Xns947C29C3EBBCcpub@.127.0.0.1...
> "Martin Knopp" <martin.knopp@.fecher.at> wrote in
news:GGVQb.304173$Tz1.135851
> @.news.chello.at:
> > I have a site running under SSL. Works well so far but there is one ASPX
> > page which returns a dynamically created PDF file using
Response.WriteFile.
> > When the browser requests this ASPX page via https (SSL) it displays a
> > message that secure and non secure items are to be displayed (free
> > translation from german so it might not be the exact wording in
english).
> > When I say no (means non secure items are not displayed) my PDF still is
> > displayed - so it seems thats not the one causing the message.
> > Any ideas whats wrong or even better how to solve it?
> It means that somewhere in the content you are sending back are some
http://
> referendces instead of https:// references. You need to make all images,
and
> other external type links https://
>
> --
> Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
> "Programming is an art form that fights back"
>
> ELKNews - Get your free copy at http://www.atozedsoftware.com
"Martin Knopp" <martin.knopp@.fecher.at> wrote in
news:Lm7Rb.314459$Tz1.163161@.news.chello.at:
> I checked for this already and the only thing we return is a PDF
> document. Nothing else.
Does the PDF have any links in it? IE shouldnt see those but..
Do a view source on the HTML and search for http://
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com
How do you display a PDF?
Do you return the PDF document with proper content type?
Or are you displaying the HTML with embeded PDF?
George.
"Martin Knopp" <martin.knopp@.fecher.at> wrote in message
news:GGVQb.304173$Tz1.135851@.news.chello.at...
> I have a site running under SSL. Works well so far but there is one ASPX
> page which returns a dynamically created PDF file using
Response.WriteFile.
> When the browser requests this ASPX page via https (SSL) it displays a
> message that secure and non secure items are to be displayed (free
> translation from german so it might not be the exact wording in english).
> When I say no (means non secure items are not displayed) my PDF still is
> displayed - so it seems thats not the one causing the message.
> Any ideas whats wrong or even better how to solve it?
> Regards,
> Martin Knopp
> fecher GmbH
I return the PDF with proper contenttype
code-behind in Page_Load event (C#) looks approximately like this:
Response.Clear();
Response.ContentType = "appilcation/pdf";
Response.WriteFile( <local path to PDF document> );
Response.End();
Regards,
Martin Knopp
fecher GmbH
http://www.fecher.at
"George Ter-Saakov" <nospam@.hotmail.com> schrieb im Newsbeitrag
news:OeFFEoC5DHA.2540@.TK2MSFTNGP11.phx.gbl...
> How do you display a PDF?
> Do you return the PDF document with proper content type?
> Or are you displaying the HTML with embeded PDF?
> George.
> "Martin Knopp" <martin.knopp@.fecher.at> wrote in message
> news:GGVQb.304173$Tz1.135851@.news.chello.at...
> > I have a site running under SSL. Works well so far but there is one ASPX
> > page which returns a dynamically created PDF file using
> Response.WriteFile.
> > When the browser requests this ASPX page via https (SSL) it displays a
> > message that secure and non secure items are to be displayed (free
> > translation from german so it might not be the exact wording in
english).
> > When I say no (means non secure items are not displayed) my PDF still is
> > displayed - so it seems thats not the one causing the message.
> > Any ideas whats wrong or even better how to solve it?
> > Regards,
> > Martin Knopp
> > fecher GmbH
go to aspx page you are using for downloads and check to see if in html view
you see any html / aspx elements (if yes remove them)
because when you call Response.Flush they will not be cleared unless you
have default Buffer = true applicable across
a better option for downloads is to use ashx... it httphandler you... they
do offer a performance boost of around 5 - 10%
--
Regards,
HD
Once a Geek... Always a Geek
"Martin Knopp" <martin.knopp@.fecher.at> wrote in message
news:tisRb.330066$Tz1.68379@.news.chello.at...
>I return the PDF with proper contenttype
> code-behind in Page_Load event (C#) looks approximately like this:
> Response.Clear();
> Response.ContentType = "appilcation/pdf";
> Response.WriteFile( <local path to PDF document> );
> Response.End();
> Regards,
> Martin Knopp
> fecher GmbH
> http://www.fecher.at
> "George Ter-Saakov" <nospam@.hotmail.com> schrieb im Newsbeitrag
> news:OeFFEoC5DHA.2540@.TK2MSFTNGP11.phx.gbl...
>> How do you display a PDF?
>> Do you return the PDF document with proper content type?
>> Or are you displaying the HTML with embeded PDF?
>>
>> George.
>>
>> "Martin Knopp" <martin.knopp@.fecher.at> wrote in message
>> news:GGVQb.304173$Tz1.135851@.news.chello.at...
>> > I have a site running under SSL. Works well so far but there is one
>> > ASPX
>> > page which returns a dynamically created PDF file using
>> Response.WriteFile.
>>> > When the browser requests this ASPX page via https (SSL) it displays a
>> > message that secure and non secure items are to be displayed (free
>> > translation from german so it might not be the exact wording in
> english).
>> > When I say no (means non secure items are not displayed) my PDF still
>> > is
>> > displayed - so it seems thats not the one causing the message.
>>> > Any ideas whats wrong or even better how to solve it?
>>> > Regards,
>> > Martin Knopp
>> > fecher GmbH
>>>>
>>
strange event postback behaviour in dynamically created usercontrol
i have an aspx page which dynamically loads a user control and adds it
to a placeholder. the control is recreated and added to the
placeholder for postbacks as well.
the user control contains a datagrid and some buttons and textboxes.
the button events fire correctly and execute their code. however, the
datagrid events fire a postback, and execute Page_load in the
usercontrol, but the Item_Command code is not executed. the code to
add events to the datagrid is in InitialiseComponent.
i have the datagrid binding in UserControl_PreRender, so that it is
bound between postbacks.
can anyone suggest why the postback is happening without the
ItemCommand event happening? i've verified this with VS debugging.
thanks
timHi Tim_Mac,
Welcome to ASP.NET newsgroup.
From your description, you've a UserControl which contains some button and
a DataGrid on it, the datagrid is subscribing some postback
events(ItemCommand). And in one of your asp.net page, you dynamically load
the usercontrol and add it on your page. However, you found the ItemCommand
of the datagrid(in usercontrol) always not fire, yes?
Based on my experience, such event handler not executing problem is likely
caused by the following things:
1. For dynamic loaded(created) controls, make sure we add them in the
Page_Init or Page_Load every time the page is requested(IsPostback or
not...).
2. For control's event handler, we also need to register them in Init or
Load event. Also, for template databound controls such as DataGrid or
DataList, we should avoid rebinding them with different datasource before
processing postback event since the event may depend on the original binded
datas.
As for your condition, since some other controls (such as button)'s event
handler execute correctly. I think the problem is likely within the
UserControl itself. Would you try registering your datagrid's ItemCommand
handler in the usercontrol's ascx template instead of programmatically
register in codebehind? Just like
<asp:datagrid ..... OnItemCommand="DataGrid_ItemCommand" ...
If you feel it convenient, I suggest you try build a simpler usercontrol
(contains a datagrid) so as to repro the problem and send it to me. Then I
can do some researchs on my side.
In addition, if you feel necessary, I can also generate a test page on my
side and let you have a compare to see whehter there are any difference.
Please feel free to let me know if you have any questions. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
hi Steven,
thank you for your most helpful reply.
i have got it working now, and will attempt to explain how and why for
future reference.
my aspx page contaings the following in Page_Load:
Modules.SportsLadder ladder =
this.LoadControl("Modules/SportsLadder.ascx") as Modules.SportsLadder;
this.serverForm.Controls.Add(ladder);
the user control is loaded regardless of whether a postback has taken
place or not.
the user control then contains a call to if(!IsPostBack) BindGrid() in
the Page_Load.
when i would delete an item in the datagrid, the page would post back,
and Page_Load would fire, but the datagrid_itemcommand event would not
fire. the datagrid would disappear from the page.
i tried adding in a PreRender event for the usercontrol, and calling
BindGrid() there, and that kept the datagrid on screen after postbacks,
but the itemcommand event still didn't fire. what got it working was i
removed the if(!IsPostBack) from the Page_Load of the user control, so
then the datagrid is bound every time. i then had the problem of the
itemcommand event being called twice (what a surprise). the reason is
because it was set in the aspx page, as Steven suggested:
<asp:datagrid ..... OnItemCommand="DataGrid_ItemCommand" ...>
but it was also set in InitialiseComponent in code. i took it out of
the code, and let the aspx handler do it.
now it works perfectly. i didn't run into any problems re-binding the
datagrid in Page_Load, my methods were still able to identify the row
that was clicked and any of the controls in the cells.
thanks for your help.
tim
strange event postback behaviour in dynamically created usercontrol
i have an aspx page which dynamically loads a user control and adds it
to a placeholder. the control is recreated and added to the
placeholder for postbacks as well.
the user control contains a datagrid and some buttons and textboxes.
the button events fire correctly and execute their code. however, the
datagrid events fire a postback, and execute Page_load in the
usercontrol, but the Item_Command code is not executed. the code to
add events to the datagrid is in InitialiseComponent.
i have the datagrid binding in UserControl_PreRender, so that it is
bound between postbacks.
can anyone suggest why the postback is happening without the
ItemCommand event happening? i've verified this with VS debugging.
thanks
timHi Tim_Mac,
Welcome to ASP.NET newsgroup.
From your description, you've a UserControl which contains some button and
a DataGrid on it, the datagrid is subscribing some postback
events(ItemCommand). And in one of your asp.net page, you dynamically load
the usercontrol and add it on your page. However, you found the ItemCommand
of the datagrid(in usercontrol) always not fire, yes?
Based on my experience, such event handler not executing problem is likely
caused by the following things:
1. For dynamic loaded(created) controls, make sure we add them in the
Page_Init or Page_Load every time the page is requested(IsPostback or
not...).
2. For control's event handler, we also need to register them in Init or
Load event. Also, for template databound controls such as DataGrid or
DataList, we should avoid rebinding them with different datasource before
processing postback event since the event may depend on the original binded
datas.
As for your condition, since some other controls (such as button)'s event
handler execute correctly. I think the problem is likely within the
UserControl itself. Would you try registering your datagrid's ItemCommand
handler in the usercontrol's ascx template instead of programmatically
register in codebehind? Just like
<asp:datagrid ..... OnItemCommand="DataGrid_ItemCommand" ...>
If you feel it convenient, I suggest you try build a simpler usercontrol
(contains a datagrid) so as to repro the problem and send it to me. Then I
can do some researchs on my side.
In addition, if you feel necessary, I can also generate a test page on my
side and let you have a compare to see whehter there are any difference.
Please feel free to let me know if you have any questions. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
hi Steven,
thank you for your most helpful reply.
i have got it working now, and will attempt to explain how and why for
future reference.
my aspx page contaings the following in Page_Load:
Modules.SportsLadder ladder =
this.LoadControl("Modules/SportsLadder.ascx") as Modules.SportsLadder;
this.serverForm.Controls.Add(ladder);
the user control is loaded regardless of whether a postback has taken
place or not.
the user control then contains a call to if(!IsPostBack) BindGrid() in
the Page_Load.
when i would delete an item in the datagrid, the page would post back,
and Page_Load would fire, but the datagrid_itemcommand event would not
fire. the datagrid would disappear from the page.
i tried adding in a PreRender event for the usercontrol, and calling
BindGrid() there, and that kept the datagrid on screen after postbacks,
but the itemcommand event still didn't fire. what got it working was i
removed the if(!IsPostBack) from the Page_Load of the user control, so
then the datagrid is bound every time. i then had the problem of the
itemcommand event being called twice (what a surprise). the reason is
because it was set in the aspx page, as Steven suggested:
<asp:datagrid ..... OnItemCommand="DataGrid_ItemCommand" ...>
but it was also set in InitialiseComponent in code. i took it out of
the code, and let the aspx handler do it.
now it works perfectly. i didn't run into any problems re-binding the
datagrid in Page_Load, my methods were still able to identify the row
that was clicked and any of the controls in the cells.
thanks for your help.
tim
Hi Tim_Mac,
Thanks a lot for your detailed response. I'm glat that you've got greate
progress on this issue. Though you've got it worked currently, I'm still
abit confusing about your detailed page and usercontrol's code logic. Based
on my understanding, as long as your UserControl is added into the page's
control collection everytime( and has a fixed it assigned to it). We don't
need to bind data to the datagrid(in the usercontrol) everytime, just in
If(! IsPostback) ) or in a postback event is ok. And the ItemCommand can
also fire correctly.
I've attached a sample page/usercontrol I used to test. You can have a test
on your side if you have interesting.
Hope helps. If there is anything else unclear, please feel free to post
here. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)