Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 732
  • Last Modified:

Associate a File to an Application for IE launch

In IE I have a link such as this..

<a href="reports/myreport.rpx">Click to Edit Report</a>

Then I have associated rpx on my PC with a program, from using open with and ticking the always.. box.

But IE still opens the file in an IE window

Is there anyway to force the machine to open the file using a program of my choice ?

I'm hoping its just a reg setting, but I couldn't find it. Access to the clients registry is not a problem for this application, since the report editor will be preinstalled from a setup program.
  • 2
  • 2
1 Solution
Currently when you click on the link, the report is being streamed to the browser with a mime type of "text/html".

To make it open in the correct program on the client machine will require you to stream the report to the browser with the correct mime type.

You can find a mime type that the client machine wants for .rpx by checking the file association on the local computer. (HKEY_CLASSES_ROOT).

If there is no mime type, or the mime type is used someplace else, e.g. text/plain, you probably won't be able to do what you want.  If it has a unique mime type, then you can change the mime type of your response from the web site to make it open in the default application.

What is the mime type (if any)?

plqAuthor Commented:
There is no mime type. The rpx file actually contains XML (active reports from data dynamics)

I have control over the app on the client that opens the rpx file (i.e. I have the source code in vb.net).

I don't know how i would tell the browser its a different mime type. Its opened with js:

            window.open(sfile, "reporteditor");

The web behind is standard asp - I suppose I could say

            window.open("rpxlaunch.asp?file=" + sfile, "reporteditor");

and in rpxlaunch.asp ...

response.contenttype = "text/mymimetype" ?
response.write ReadTextFile(Request.QueryString("file"))

How does that sound?

Here's a typical rpx file

<?xml version="1.0" encoding="UTF-8"?>
<ActiveReportsLayout Version="3" PrintWidth="14535" DocumentName="sysAssetRegisterByCategory" ScriptLang="C#" ShowParamUI="0" CodeFile="sysTest.vb">
    <Style Name="Normal" Value="font-family: 'Arial'; font-style: normal; font-variant: inherit; font-weight: normal; font-size: 10pt; font-size-adjust: inherit; font-stretch: inherit; color: rgb(0,0,0); background-color: inherit; background-image: inherit; background-repeat: inherit; background-attachment: inherit; opacity: inherit; word-spacing: inherit; letter-spacing: inherit; text-decoration: none; vertical-align: inherit; text-transform: inherit; text-align: inherit; text-indent: inherit; unicode-bidi: inherit; line-height: inherit; white-space: inherit; ddo-char-set: 0; " />
    <Style Name="Heading1" Value="font-family: 'inherit'; font-style: inherit; font-variant: inherit; font-weight: bold; font-size: 16pt; font-size-adjust: inherit; font-stretch: inherit; " />
    <Style Name="Heading2" Value="font-family: 'Times New Roman'; font-style: italic; font-variant: inherit; font-weight: bold; font-size: 14pt; font-size-adjust: inherit; font-stretch: inherit; " />
    <Style Name="Heading3" Value="font-family: 'inherit'; font-style: inherit; font-variant: inherit; font-weight: bold; font-size: 13pt; font-size-adjust: inherit; font-stretch: inherit; " />
    <Section Type="Detail" Name="Detail" Height="254" BackColor="16777215" KeepTogether="1" CanGrow="0">
      <Control Type="AR.Field" Name="txtCompanyCompanyDesc18" DataField="CostCentreName" MOD="4" Left="0" Top="0" Width="2000" Height="235" Text="CostCentreName" Style="color: rgb(0,0,0); ddo-char-set: 0; text-align: left; background-color: rgb(255,255,255); font-size: 8pt; " />
  <PageSettings />
The web behind is standard asp - I suppose I could say

          window.open("rpxlaunch.asp?file=" + sfile, "reporteditor");

and in rpxlaunch.asp ...

response.contenttype = "text/mymimetype" ?
response.write ReadTextFile(Request.QueryString("file"))

How does that sound?

That soulds like a possibility, but to get it to work I think you will have to associate a mime type on the client computer.  I also went looking for a mime type related to rpx and could not find one.

I think you are on the right track.
plqAuthor Commented:
This is working now. I can now open an rpx straight into my vb.net editor

Here's the JS

     window.open("reportedit.asp?file=" + sfile, "reporteditor")

Here's the reportedit.asp page (asp3 sadly)

      Response.ContentType = "application/rpx"
      sFile = Request.QueryString("file")
      Response.Write ReadTextFile(Server.MapPath(".") & "\" & Replace(sFile, "/", "\"), 0)
Function ReadTextFile(sName, bUnicode)
    Dim scr
    Dim txt
    Dim sBuffer
    Dim lCount
    Set scr = CreateObject("Scripting.FileSystemObject")
    Set txt = scr.OpenTextFile(CStr(sName), 1, false, CBool(bUnicode))
    If txt.AtEndOfStream Then
        ReadTextFile = ""
        ReadTextFile = txt.ReadAll()
    End If
    Set txt = Nothing
    Set scr = Nothing
End Function


And here's the reg file needed on the client... this reg setting seems to make it use the windows default for rpx (e.g. open from windows explorer file association), which is just what I wanted

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/rpx]

I am fairly sure this will be of interest to other activereports enduserdesigner developers :)

thanks for helping

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now