Thursday, March 22, 2012

Open a remote htm file

We have catalogs that are supplied to us and are basically websites on cd's (with all the navigation built in). These are then copied to a shared data server. From my webpage, I determine which catalog the user needs. What I want to do then is simply open the index file of the virtual site in a new window. The path could be something like "C:\catalogs\electrical\summer2007\index.htm" This new browser then facilitates all the searching and navigation for the particular catalog. Basically open a htm file from a dataserver (as opposed to webserver) in a new window.

Any thoughts?

You can use some bits and pieces in System.IO to find, open and read the contents of files. The current Article of the Day should help:http://www.beansoftware.com/ASP.NET-Tutorials/Manipulating-Files-Directories.aspx


i just built one today.

a) Put a literal control on your page like <asp:Literal id="myLit" runat="Server"/>

b) Codebehind.

StreamReader sr = new StreamReader("PathtoMyFileandMyfileName.htm");
try{
myLit.Text = sr.ReadToEnd();
}catch(Exception ex){
throw(ex); //throw error
}

hth.

mcm


Have you considered Response.Redirect? Like...

Response.Redirect("path of catalog");
Thanks for the help. I'm getting an error when the page is loading. "Compiler Error Message:BC30519: Overload resolution failed because no accessible 'New' can be called without a narrowing conversion" Here's the line of code:

Dim volume ="\\servername\catalogs\014753\" & ddlVolumeList.SelectedValue.ToString &"\c1\index.htm" (var 'volume' gives the correct path on debugging)

Dim srAsNew StreamReader(volume)

Any thoughts?


Dim volume ="\\servername\catalogs\014753\" & ddlVolumeList.SelectedValue.ToString &"\c1\index.htm" (var 'volume' gives the correct path on debugging)

The address in the browser after "Response.Redirect(volume) ishttp://domain.com/Servername/catalogs/summer2007/c1/index.htm

This portion is correctServername/catalogs/summer2007/c1/index.htm but I need the URL to be\\servername\catalogs\summer2007\c1\index.htm.If I just paste that into the address bar of the browser it finds and loads my page correctly.

Any clues?


Hi,

Based on my understanding, you want to redirect the user to another page, which is in another machine, from your asp.net application. If I have misunderstood you, please feel free to let me know.

When we use the Response's Redirect method to redirect the user,this Url can be an full URL beginning with "http://", a virtual path to a location on thesame IIS server, or the name of a file contained in thesame location as the original URL. For more information, seehttp://msdn2.microsoft.com/en-us/library/ms524309.aspx.

If we want to request the page that is in another machine within browser, we can deploy a website which contains these pages on another machine, and then request these pages from your application.


I hope this helps.


In classic asp I was able to do this with client side BLOCKED SCRIPT

strImageLocation ="\\servername\catalogs\014753\" & ddlVolumeList.SelectedValue.ToString &"\c1\index.htm""

document.write ("<A name='GetImages' target='New' style='visibility:hidden' HREF='" & strImageLocation &"'> </a>")

Document.all("GetImages").click

Does anyone know how I can do this either client or server side in asp.net 2.0 (preferably VB)?

0 comments:

Post a Comment