Redirecting to Network file.

  • Thread starter Thread starter Tim Marsden
  • Start date Start date
T

Tim Marsden

Hi,

I would like to redirect my browser to a Network file (not on the Web
Server), whrn a button is clicked.
For example a Excel workbook.

I would like options to open it in Excel, in the Browser or download it to
my local Machine.

I am using VB.NET and ASP.NET

Regards
Tim
 
If is is going to be a File then you can use the File:// protocl tag to
inform IE to open from a file Location. You can directly point to the
Network location provided your users are always going to be mapped to
this particulr location.

(OR)

this is not what you asked for, but you can grant access to the File
Server Share to an account that the ASP.NEt application can impersonate
under. Then you can read from the File Server and send the data as
binary data to the client or you can also create a IIS Virtual Directoy
and use the links to navigate to them. I would use the later.

In Fact to make life easier we had actually installed a web server along
with the file server which does nothing more than serve static files.

Regards,

Trevor Benedict R
MCSD

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Hi Tim,

As for the problem on retrieve a Network file and write down to the
response stream, do you mean the file on a remote machine and can access
via UNC path like \\servername\sharedfolder\filename?

This is ok in asp.net, we can just use the Response.WriteFile method to
write a file to response stream via a UNC path. Or use the System.IO api to
retrieve the file into a stream and write it into the Response 's
OutputStream.
For example:
private void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "Application/vnd.ms-excel";
string FilePath = @"\\servername\tempshare\test.xls";
Response.WriteFile(FilePath);
Response.End();

}

Here are the kb articles on write binary files to response:
#HOW TO: Write Binary Files to the Browser Using ASP.NET and Visual C# .NET
http://support.microsoft.com/?id=306654

#HOW TO: Write Binary Files to the Browser Using ASP.NET and Visual Basic
..NET
http://support.microsoft.com/?id=307603

#The key point is that access a remote file need the asp.net process run
under a appropriate account, by default the local MACHINE\ASPNET account
won't work. One way it to use impersonate the asp.net with a powerful
domain account or a mapped local account on both local and remote machine.
As for impersonate, you can refer to the followinng kb article:

#INFO: Implementing Impersonation in an ASP.NET Application
http://support.microsoft.com/?id=306158

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Hi Tim,

Have you had a chance to check out the suggestions in my last reply or have
you got any further ideas on this issue? If there're anything else we can
help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Back
Top