Link to home
Start Free TrialLog in
Avatar of cjinsocal581
cjinsocal581Flag for United States of America

asked on

response.redirect issue

Server: Win2003
IIS Ver: 6

Problem: Response.Redirect does not open VCS file.

Code:
____________________________________________________________________________
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=UTF-8" http-equiv=Content-Type>
<META content="MSHTML 5.00.3207.2500" name=GENERATOR></HEAD>
<BODY>

<FORM method=post action="testvcal.asp" name="VCal">
<pre>
<P align=center><FONT face=Verdana size=4>
    <STRONG>VCalendar Test Page</STRONG></FONT></P>
<%
    Dim DTStart, DTEnd, Subject, Location
    Dim Description, OutputFilePath
    Dim fMissingCriticalData, strMsg, Pass

      DTStart = Request.Form("DTStart")
      DTEnd = Request.Form("DTEnd")
      Subject = Request.Form("Subject")
      Location = Request.Form("Location")
      Description = Request.Form("Description")
      OutputFilePath = Request.Form("OutputFilePath")
      Pass = Request.Form("Pass")
      
    fMissingCriticalData=0
      strMsg = ""
   
    ' Put some default values in input boxes
      If Len(Subject) = 0 Then Subject = "Undetermined"
      If Len(Location) = 0 Then Location = "Undetermined"
      If Len(Description) = 0 Then Description = "Undetermined"
      If Len(OutputFilePath) = 0 Then  OutputFilePath ="C:\"
      If Len(Pass) = 0 Then Pass = 0

      If Pass > 0 Then
          If Len(DTStart)= 0 OR Not IsDate(DTStart) Then
            fMissingCriticalData=1
            strMsg = strMsg & "<Font color=red>Missing valid start date and time.</Font><BR>"
          End If
      
          If Len(DTEnd)= 0 OR Not IsDate(DTEnd) Then
            fMissingCriticalData=1
            strMsg = strMsg & "<Font color=red>Missing valid end date and time.</Font><BR>"
          End If
      
      Else
          strMsg = "<B>Provide the following information to create the appointment item.</b>"
      End If
      
      If fMissingCriticalData=1 or pass=0 Then
            Response.Write(strMsg)
%>
            <BR>
            <FONT face=Veranda size=3>
                  <INPUT id=txtPass name=Pass style="VISIBILITY: hidden" value="<%=Pass + 1%>">
                  
            <TABLE Border=0 align=center>
              <TBODY>
              <tr>
                 <td>Start Date and Time:</td>
                 <td><INPUT align=right id=txtDTStart name=DTStart value=<%=DTStart%>></td>
                 <td>(Format: mm/dd/yy hh:nn am/pm)</td>
              </tr>
              <tr>
                 <td>End Date and Time:</td>
                 <td><INPUT align=right id=txtDTEnd name=DTEnd value=<%=DTEnd%>></td>
                 <td>(Format: mm/dd/yy hh:nn am/pm)</td>
              </tr>
              <tr>
                 <td>Subject:</td>
                 <td><INPUT align=right id=txtSubject name=Subject value=<%=Subject%>></td>
                 <td></td>
              </tr>
              <tr>
                 <td>Location:</td>
                 <td><INPUT align=right id=txtLocation name=Location value=<%=Location%>></td>
                 <td></td>
              </tr>
              <tr>
                 <td>Description:</td>
                 <td><INPUT align=right id=txtDescription name=Description value=<%=Description%>></td>
                 <td></td>
              </tr>
              <tr>
                 <td>Output File Path:</td>
                 <td><INPUT align=right id=txtOutputFilePath name=OutputFilePath value=<%=OutputFilePath%>></td>
                 <td></td>
              </tr>
              <tr>
                 <td></td>
                 <td><INPUT id=submit1 name=submit1 type=submit value=Submit></td>
                 <td><INPUT id=reset1 name=reset1 type=reset value=Reset></td>
              </tr>

            </TBODY>
            </FONT>
            </TABLE>
        
<%

      Else
            If Len(Subject) = 0 Then Subject = "(No Subject Given)"
            If Len(Location) = 0 Then Location = "(No Location Given)"
            If Len(Description) = 0 Then Description = "(No Description Given)"
      
            Dim objVCal, VCalFile
            Set objVcal = Server.CreateObject("VCalWrap.ApptItem")

            With objVCal
                  .DTStart = DTStart
                  .DTEnd = DTEnd
                  .Subject = Subject
                  .Location = Location
                  .Description = Description
                  .OutputFilePath = OutputFilePath
                  .TimeZoneBias = -7
                  .CreateVCSEvent
                  VCalFile = .VCalFile
            End With
            Response.redirect(VCalFile)

      End If

%>
</Pre>
</FORM>
</BODY></HTML>
__________________________________________________________________________

Bottom line: Trying to get the VCalFile to open up once it is created. Ideas?
Avatar of cjinsocal581
cjinsocal581
Flag of United States of America image

ASKER

If you want to run this, you will need the DLL from this site:

http://www.serverwatch.com/tutorials/article.php/10825_1475511_1
Avatar of masirof
masirof

What is the error?
You have right permissions?
Response object error 'ASP 0158 : 80004005'

Missing URL

/calendar/testvcal.asp, line 119

A URL is required.
agreed, looks like VcalFile is not a valid URL, do a

response.write VCalFile

to see whats in it and post it here
Just produces a blank page.
Check properties of that redirected page. Check if that is the destination.
You may want to turn off friendly errors on advaced tab of internet option in IE.
Also please check source code.
Please let know if there anything.
It is not a page guys. It is a file that has been created. Please re-read through the entire code above.

I need it to pop my Outlook application when it is created as a VCS file. (Calendar item)
Can you open created by doulbe-clicking on it?
Yes I can, but the issue is getting it to open once it is created from the page. My users will not have access to the directory where the VCS files are being created.
Ok,
To do this you have to force download, meaning showing up a download dialog box, right?
Change headers, and you should be able doing it.
ASKER CERTIFIED SOLUTION
Avatar of AlfaNoMore
AlfaNoMore

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
We are getting closer.

It now pops up the dialog to download the file but the file it wants to download is the acutal asp page instead of the VCS file.

Ideas?
Sorry, you're going to need to uncomment the Response.Addheader line. Just noticed that!!!!
Ok, let me try.
This time I got the dialog box, but the file that was downloaded had this in it:
_________________________________________________________________________

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=UTF-16" http-equiv=Content-Type>
<META content="MSHTML 5.00.3207.2500" name=GENERATOR></HEAD>
<BODY>

<FORM method=post action="testvcal.asp" name="VCal">
<pre>
<P align=center><FONT face=Verdana size=4>
    <STRONG>VCalendar Test Page</STRONG></FONT></P>

</Pre>
</FORM>
</BODY></HTML>
_____________________________________________________________________
Any ideas?
Are you sure you are creating right type of file.
You said you are able to create file and open it by double clicking.

Issue is here, as I said before, to create right type of file, and force it for download using headers.
Please try.
This is the code I have in place:
___________________________________
   If Len(Subject) = 0 Then Subject = "(No Subject Given)"
          If Len(Location) = 0 Then Location = "(No Location Given)"
          If Len(Description) = 0 Then Description = "(No Description Given)"
     
          Dim objVCal, VCalFile
          Set objVcal = Server.CreateObject("VCalWrap.ApptItem")

          With objVCal
               .DTStart = DTStart
               .DTEnd = DTEnd
               .Subject = Subject
               .Location = Location
               .Description = Description
               .OutputFilePath = OutputFilePath
               .TimeZoneBias = -7
               .CreateVCSEvent
               VCalFile = .VCalFile
          End With

          Response.ContentType = "application/" & file_type
          'Response.AddHeader "Content-Disposition", "attachment; filename=" & OutputFilePath
          Response.BinaryWrite(VCalFile)
__________________________________________-

But it creates the asp file. Not the VCS, what am I missing?
You mean its extension is .ASP?
Extension should be VCS's extension.
sorry,

there is no extension on the file when it is prompted to be downloaded.

So, when I download it and open it with notepad, the asp page code is there, not the VCS code. (Asp page without the VBScript syntax of course)
This is what is in the file:
_________________________________________________________________________

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=UTF-16" http-equiv=Content-Type>
<META content="MSHTML 5.00.3207.2500" name=GENERATOR></HEAD>
<BODY>

<FORM method=post action="testvcal.asp" name="VCal">
<pre>
<P align=center><FONT face=Verdana size=4>
    <STRONG>VCalendar Test Page</STRONG></FONT></P>

</Pre>
</FORM>
</BODY></HTML>
_____________________________________________________________________
I figured it out. I just needed to point to the different file.