RE: from Displaying a Document using the ASPNET user account to the Client Browser discussion (3/2/2004
Buddy
Thanks for helping me on getting the document to display. But now I am left with a second issue. While I was displaying the document as an attachment I end up with an extra window open or if I remove the Target='_blank' then my main window goes blank
What I am doing is using the base code from http://www.eggheadcafe.com/articles/20021207.asp that I used to help me transfer my Classic Session Variables from the base ASP code to the ASP.NET code which actually does the "viewdocument.aspx" work. My problem is that when I pass from main.asp->ASPTOASPX.asp->viewdocument.aspx I then get stuck with the blank window. I have tried using Redirects and Server.Transfers at the bottom of the page. But the code appears to freeze up after the document gets displayed. Any thoughts
<%@ Page ASPCompat="true" %><%@ Import Namespace="System.IO" %><%@ Import Namespace="System" %><%@ Import Namespace="System.net" %><%@ Import Namespace="System.text" %><%@ Import Namespace="System.Data.SqlClient" %><
Dim strdoc, objRS, objConn, strdoctype, objRS
Dim strSQL as StringBuilde
Dim strSQLC as StringBuilde
Dim FileName as StringBuilde
strdoc = Session("Parm1"
'1- Get file informatio
Dim conPubs as SqlConnectio
Dim cmdSelect as SqlComman
Dim dtrSelect as SqlDataReade
Dim conPubsC as SqlConnectio
Dim cmdSelectC as SqlComman
Dim dtrSelectC as SqlDataReade
conPubs = New SqlConnection( ---------
conPubs.Open(
strSQL = new System.Text.StringBuilder(
strSQL.Append("Select query"
cmdSelect = New SqlCommand(strSQL.ToString(), conPubs
dtrSelect = cmdSelect.ExecuteReader(
While dtrSelect.Read(
'2- Validate that the user can view this catagory of documen
if CheckAccess(dtrSelect("doccatagory"))="Y" the
conPubsC = New SqlConnection("-------"
conPubsC.Open(
'3- Get the ContentType information using the document's doctyp
strdoctype="." + dtrSelect("doctype"
' Retreive content type informatio
strSQLC = new System.Text.StringBuilder(
strSQLC.Append("Select * from ContentTypes where Class='"
strSQLC.Append(strdoctype
strSQLC.Append("'"
cmdSelectC = New SqlCommand(strSQLC.ToString(), conPubsC
dtrSelectC = cmdSelectC.ExecuteReader(
While dtrSelectC.Read(
'4- Only allow display of valid contenttypes
if dtrSelectC("status")="Y" the
Dim MyFileInfo As FileInf
Dim StartPos, FileSize As Lon
Dim header As String = "attachment;filename=Document1" & strdoctyp
FileName = new System.Text.StringBuilder(
FileName.Append("f:\inetpub\"
FileName.Append(dtrSelect("filename")
FileName.Append("/"
FileName.Append(dtrSelect("doccatagory")
FileName.Append("/"
FileName.Append(dtrSelect("docnumber")
FileName.Append("."
FileName.Append(dtrSelect("doctype")
MyFileInfo = New FileInfo(FileName.ToString()
FileSize = MyFileInfo.Length
response.contenttype = dtrSelectC("ContentType"
Response.AddHeader("Content-Disposition",header
Response.WriteFile(FileName.ToString(), StartPos, FileSize
End if 'End of Valid ContentTyp
End Whil
dtrSelectC.Close(
conPubsC.Close(
End if 'End of Check Access allowe
End Whil
dtrSelect.Close(
conPubs.Close(
'RetPage is the variable containing the original UR
Session("DestPage")=Session("RetPage"
Server.Transfer("ASPXTOASP.aspx"
%>