Home All Groups Group Topic Archive Search About
Author
14 Dec 2006 6:12 AM
David Thielen
Hi;

I have a HyperLinkField and have set  Target="_blank" in the properties.
When I click on it it asks me if I want to save or open the file. I sthere a
way to have it always just open the file?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Author
14 Dec 2006 12:53 PM
Walter Wang [MSFT]
Hi Dave,

This prompt is controlled by user, it's not possible to force open it
either in server-side code or javascript code. It's for security reason,
you don't want a web site to open arbitrary file automatically. When the
user gets the prompt, he/she can uncheck the "Always ask before opening
this type of file", -- which saves the setting in registry:
HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\AttachmentExecute.

On the other hide, we can do the opposite thing: we can force a file always
to be downloaded instead of open directly by setting Content-Type and
Content-Disposition headers"

#How To Raise a "File Download" Dialog Box for a Known MIME Type
http://support.microsoft.com/default.aspx/kb/260519


Sincerely,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
14 Dec 2006 10:11 PM
David Thielen
this is weird because it even does it for html files - yet normally when I
click on a link that launches anohter window - it just does it.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Show quoteHide quote
"Walter Wang [MSFT]" wrote:

> Hi Dave,
>
> This prompt is controlled by user, it's not possible to force open it
> either in server-side code or javascript code. It's for security reason,
> you don't want a web site to open arbitrary file automatically. When the
> user gets the prompt, he/she can uncheck the "Always ask before opening
> this type of file", -- which saves the setting in registry:
> HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\AttachmentExecute.
>
> On the other hide, we can do the opposite thing: we can force a file always
> to be downloaded instead of open directly by setting Content-Type and
> Content-Disposition headers"
>
> #How To Raise a "File Download" Dialog Box for a Known MIME Type
> http://support.microsoft.com/default.aspx/kb/260519
>
>
> Sincerely,
> Walter Wang (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications. If you are using Outlook Express, please make sure you clear the
> check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
> promptly.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
Author
15 Dec 2006 12:22 AM
Walter Wang [MSFT]
Do you mean that following html tag will prompt the user to open/save the
html file?

<a href="test.htm" target="_blank">test.htm</a>


and what if you remove the target attribute?


Does only one machine has this issue or all have it?


Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
15 Dec 2006 6:36 AM
David Thielen
Not exactly - I have a HyperLinkField with the following:

DataNavigateUrlFields="ID, Ext"
DataNavigateUrlFormatString="~/report-view.{1}?ID={0}" Target="_blank" - I'm
not sure how this is handled by ASP.NET.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Show quoteHide quote
"Walter Wang [MSFT]" wrote:

> Do you mean that following html tag will prompt the user to open/save the
> html file?
>
> <a href="test.htm" target="_blank">test.htm</a>
>
>
> and what if you remove the target attribute?
>
>
> Does only one machine has this issue or all have it?
>
>
> Regards,
> Walter Wang (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
Author
15 Dec 2006 8:33 AM
Walter Wang [MSFT]
What's the result html looks like? The HyperLinkField is generating html
content such as:

<a href="report-view.htm?ID=15" target="_blank">here</a>

If the ID=15 and Ext=htm.



Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
16 Dec 2006 8:46 PM
David Thielen
Here is the actual html from "view source" on the generated page:

<a onMouseOver="this.firstChild.src='images/button_over.gif';"
onMouseOut="this.firstChild.src='images/button.gif';"
onClick="this.firstChild.src='images/button_click.gif';"
href="report-view.html?ID=101" target="_blank"><img src="images/button.gif"
alt="view the report mondays" style="border-width:0px;" /></a>

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Show quoteHide quote
"Walter Wang [MSFT]" wrote:

> What's the result html looks like? The HyperLinkField is generating html
> content such as:
>
> <a href="report-view.htm?ID=15" target="_blank">here</a>
>
> If the ID=15 and Ext=htm.
>
>
>
> Regards,
> Walter Wang (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
Author
17 Dec 2006 5:15 AM
Walter Wang [MSFT]
I've tested it on my side, it's still working correctly, I don't see the
open/save prompt for a simple .html file.

1) Does it work if you remove the 'target="_blank"' attribute?
2) Does this only reproduce on a specific client system?
3) Does it reproduce using only static html files?
4) Does it reproduce using .htm extension?
5) Would you please try to use Fiddler to see the response's Content-Type
header?

Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
17 Dec 2006 11:13 PM
David Thielen
Hi;

I started my ASP.NET app and then created the file below trying both .html
and .htm and when I click on the link I get prompted.

Here is the file:
<html>
<body>
<a onMouseOver="this.firstChild.src='images/button_over.gif';"
onMouseOut="this.firstChild.src='images/button.gif';"
onClick="this.firstChild.src='images/button_click.gif';"
href="report-view.htm?ID=101" target="_blank"><img src="images/button.gif"
alt="view the report mondays" style="border-width:0px;" /></a>
</body>
</html>
Author
17 Dec 2006 11:15 PM
David Thielen
One follow-on note. This is not an actual file on my system. This file is
handled by:
    <httpHandlers>
        <add verb="*" path="report-view.*" type="ReportView"/>
    </httpHandlers>

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Show quoteHide quote
"Walter Wang [MSFT]" wrote:

> I've tested it on my side, it's still working correctly, I don't see the
> open/save prompt for a simple .html file.
>
> 1) Does it work if you remove the 'target="_blank"' attribute?
> 2) Does this only reproduce on a specific client system?
> 3) Does it reproduce using only static html files?
> 4) Does it reproduce using .htm extension?
> 5) Would you please try to use Fiddler to see the response's Content-Type
> header?
>
> Regards,
> Walter Wang (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
Author
19 Dec 2006 6:30 AM
Walter Wang [MSFT]
Would you please show some code of your custom http handler?

Also, what's the output's content-type?


Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
21 Dec 2006 5:54 PM
David Thielen
Here is the entire class. I think it's the bottom 4 or 5 lines that matter.

/*
* Copyright (c) 2006 by Windward Studios, Inc. All rights reserved.
*
* This software is the confidential and proprietary information of Windward
Studios ("Confidential Information"). 
* You shall not disclose such Confidential Information and shall use it
only in accordance with the terms of the
* license agreement you entered into with Windward Studios, Inc.
*/

using System.Web;
using System;
using System.Web.SessionState;
using net.windward.portal;
using net.windward.api.csharp;
using System.IO;
using net.windward.portal.net.data;
using net.windward.portal.security;
using net.windward.portal.audit;

/// <summary>
/// Displays the report requested by the url.
/// </summary>
public class ReportCreate : IHttpHandler, IRequiresSessionState
{

    public const string IMAGES_DIR = "temp-images";

    #region IHttpHandler Members

    public bool IsReusable
    {
        get { return false; }
    }

    /// <summary>
    /// Create a report and return it as the page.
    /// </summary>
    /// <param name="context">The request context.</param>
    public void ProcessRequest(HttpContext context)
    {
        // make sure is a user. Checks access rights to this template below.
        if (!PortalRole.IsInRole((PortalRole.ROLES.USER)))
            throw new PortalSecurityException(PortalSecurityException.TYPE.NEED_ROLE,
PortalRole.ROLES.USER.ToString());

        int id;
        try
        {
            id = Convert.ToInt32(context.Request.QueryString["wr_id"]);
        }
        catch (Exception ex)
        {
            throw new InvalidParametersException("wr_id",
context.Request.QueryString["wr_id"], ex);
        }
        ReportItem.FORMAT format;
        try
        {
            format =
ExtensionConvert.ToFormat(context.Request.QueryString["wr_format"]);
        }
        catch (Exception ex)
        {
            throw new InvalidParametersException("wr_format",
context.Request.QueryString["wr_format"], ex);
        }

        // set up the maps - we use for all datasources
        KeyPairDictionary vars = new KeyPairDictionary();
        for (int ind = 0; ind < context.Request.QueryString.Count; ind++)
        {
            string key =
HttpUtility.UrlDecode(context.Request.QueryString.GetKey(ind));
            if (!key.StartsWith("wr_"))
                vars.Add(key,
HttpUtility.UrlDecode(context.Request.QueryString.Get(ind)));
        }

        Report report = GenerateReport.Create(id, format, vars,
context.Server.MapPath(IMAGES_DIR), IMAGES_DIR, "wr");
        Auditor.Log(Auditor.MODULE.REPORT, Auditor.OPERATION.CREATE,
context.Request.RawUrl);

        // track image files created
        if (report is ReportHtml)
            foreach (HtmlBitmap bitmap in ((ReportHtml)report).Bitmaps)
                Global.AddTempFile(context.Session, bitmap.Filename);

        context.Response.Clear();
        context.Response.ClearHeaders();
        context.Response.ClearContent();

        context.Response.ContentType = ExtensionConvert.ToContentType(format); //
returns MediaTypeNames.Text.Html
        ((MemoryStream)report.GetReport()).WriteTo(context.Response.OutputStream);

        context.Response.End();
    }

    #endregion

}


--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Show quoteHide quote
"Walter Wang [MSFT]" wrote:

> Would you please show some code of your custom http handler?
>
> Also, what's the output's content-type?
>
>
> Regards,
> Walter Wang (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
Author
24 Dec 2006 2:24 AM
Walter Wang [MSFT]
Hi Dave,

I just tried again using a custom http handler and unfortunately I still
wasn't able to reproduce the issue. Since I don't have your report code,
I'm using following simple http handler:

/// <summary>
/// Displays the report requested by the url.
/// </summary>
public class ReportCreate : IHttpHandler, IRequiresSessionState
{

    public const string IMAGES_DIR = "temp-images";

    #region IHttpHandler Members

    public bool IsReusable
    {
        get { return false; }
    }

    /// <summary>
    /// Create a report and return it as the page.
    /// </summary>
    /// <param name="context">The request context.</param>
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = MediaTypeNames.Text.Html;
        string text = "Hello";
        MemoryStream ms = new MemoryStream();
        byte[] buf = Encoding.ASCII.GetBytes(text);
        ms.Write(buf, 0, buf.Length);
        ms.Seek(0, SeekOrigin.Begin);
        ms.WriteTo(context.Response.OutputStream);
        context.Response.End();
    }

    #endregion

}

Here's my web.config:

<system.web>
    <httpHandlers>
      <add verb="*" path="report-view.*" type="ReportCreate, __code" />
    </httpHandlers>
...

HomePage.htm:

    <a href="report-view.htm" target="_blank">Report View</a>


report-view.htm doesn't exist.

When I view HomePage.htm in browser, it correctly opens a new window and
shows "Hello".

I noticed you haven't confirmed whether this issue exist on a specific
client or not.

If it exists on all you system, would you please help me to create a more
complete reproducible project? Thanks.



Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
2 Jan 2007 6:31 PM
David Thielen
Hi;

Ok, I figured you know this well and your code works. So I took your code,
it worked on mine. I then looked for differences and here is the problem I
had:

context.Response.AddHeader("Content-Disposition", "attachment;filename=" +
ri.Title + ext);

Got rid of that and now it's fine.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Show quoteHide quote
"Walter Wang [MSFT]" wrote:

> Hi Dave,
>
> I just tried again using a custom http handler and unfortunately I still
> wasn't able to reproduce the issue. Since I don't have your report code,
> I'm using following simple http handler:
>
> /// <summary>
> /// Displays the report requested by the url.
> /// </summary>
> public class ReportCreate : IHttpHandler, IRequiresSessionState
> {
>
>     public const string IMAGES_DIR = "temp-images";
>
>     #region IHttpHandler Members
>
>     public bool IsReusable
>     {
>         get { return false; }
>     }
>
>     /// <summary>
>     /// Create a report and return it as the page.
>     /// </summary>
>     /// <param name="context">The request context.</param>
>     public void ProcessRequest(HttpContext context)
>     {
>         context.Response.ContentType = MediaTypeNames.Text.Html;
>         string text = "Hello";
>         MemoryStream ms = new MemoryStream();
>         byte[] buf = Encoding.ASCII.GetBytes(text);
>         ms.Write(buf, 0, buf.Length);
>         ms.Seek(0, SeekOrigin.Begin);
>         ms.WriteTo(context.Response.OutputStream);
>         context.Response.End();
>     }
>
>     #endregion
>
> }
>
> Here's my web.config:
>
> <system.web>
>     <httpHandlers>
>       <add verb="*" path="report-view.*" type="ReportCreate, __code" />
>     </httpHandlers>
> ...
>
> HomePage.htm:
>
>     <a href="report-view.htm" target="_blank">Report View</a>
>
>
> report-view.htm doesn't exist.
>
> When I view HomePage.htm in browser, it correctly opens a new window and
> shows "Hello".
>
> I noticed you haven't confirmed whether this issue exist on a specific
> client or not.
>
> If it exists on all you system, would you please help me to create a more
> complete reproducible project? Thanks.
>
>
>
> Regards,
> Walter Wang (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
Author
3 Jan 2007 1:59 AM
Walter Wang [MSFT]
Dave,

I'm glad that you've found the cause. Yes this header is used to force
browser download the file.

Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
19 Dec 2006 12:18 AM
David Thielen
One more follow-on note. That same page has a standard <a href=... to an html
file that exists with target='_blank' - and it pops up with no prompt. So it
appears to be something about it being returned by a program and/or the fact
that there is javascript involved.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Show quoteHide quote
"Walter Wang [MSFT]" wrote:

> I've tested it on my side, it's still working correctly, I don't see the
> open/save prompt for a simple .html file.
>
> 1) Does it work if you remove the 'target="_blank"' attribute?
> 2) Does this only reproduce on a specific client system?
> 3) Does it reproduce using only static html files?
> 4) Does it reproduce using .htm extension?
> 5) Would you please try to use Fiddler to see the response's Content-Type
> header?
>
> Regards,
> Walter Wang (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>