Solved

Response.Redirect if Application.Lock() is in use

Posted on 2004-04-06
4
416 Views
Last Modified: 2012-05-04
I have a page which locks the application it contains. (Page's code is below) What I need to do is have the code check to see if the application is running, or, if the Application.Lock() has been applied (if possible). If so, I would like to use a Response.Redirect to output to another page. (Let's say 403.htm, for the sake of this issue)

Here is the code:

<%
Application.Lock()
Tag = Request("Tag")
Set FileSys = Server.CreateObject("Scripting.FileSystemObject")
FileName = FileSys.GetTempName
Set WShShell = Server.CreateObject("WScript.Shell")
IP = Request.Form("Target")
if Request("vbOption") = "no"  then
RetCode = WShShell.Run("d:\CodeRelease\spirituality561\CVSRoot\callantbuildUNIX.cmd " & Tag & " " & "DEV " & FileName, 1, True)
else
RetCode = WShShell.Run("d:\CodeRelease\spirituality561\CVSRoot\callantbuildUNIXVB.cmd " & Tag & " " & "DEV " & FileName, 1, True)
end if
Set TextFile = FileSys.OpenTextFile("d:\CodeRelease\spirituality561\CVSRoot\" & FileName & ".txt", 1)
TextBuffer = TextFile.ReadAll
if instr(textbuffer,"BUILD SUCCESSFUL")>0 then
buildsuccess="BUILD SUCCESSFUL"
else
buildsuccess="BUILD FAILED"
End If
For i = 1 to Len(TextBuffer)
If Mid(TextBuffer,i,1) = chr(13) Then
Response.Write("<BR>")
else
Response.Write(Mid(TextBuffer,i,1))
end if
Next
TextFile.Close
FileSys.DeleteFile "d:\CodeRelease\spirituality561\CVSRoot\" & FileName & ".txt"
Application.Unlock()
%>
<TITLE><%=buildsuccess%></TITLE>
<BR><BR>
<CENTER>

<script>
function buildSuccessful()
      {
      answer = confirm("Build SUCCESSFUL, Deploy to Development?");

      if (answer !=0)
            {
            location = "/spirituality561/devdeployUNIX.asp?Tag=<%=Tag%>";
            }
      }
</script>

<%if buildsuccess="BUILD SUCCESSFUL" then%>
<script>
buildSuccessful();
</script>
<%end if%>

0
Comment
Question by:boucherc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 21

Accepted Solution

by:
ap_sajith earned 125 total points
ID: 10773089
Try something like...

<%
If Application("IsLocked")=1 Then
      Response.Redirect "Page.asp?err=true"
Else
      Application.Lock()
      Application("IsLocked")=1
      Tag = Request("Tag")
      Set FileSys = Server.CreateObject("Scripting.FileSystemObject")
      FileName = FileSys.GetTempName
      Set WShShell = Server.CreateObject("WScript.Shell")
      IP = Request.Form("Target")
      if Request("vbOption") = "no"  then
      RetCode = WShShell.Run("d:\CodeRelease\spirituality561\CVSRoot\callantbuildUNIX.cmd " & Tag & " " & "DEV " & FileName, 1, True)
      else
      RetCode = WShShell.Run("d:\CodeRelease\spirituality561\CVSRoot\callantbuildUNIXVB.cmd " & Tag & " " & "DEV " & FileName, 1, True)
      end if
      Set TextFile = FileSys.OpenTextFile("d:\CodeRelease\spirituality561\CVSRoot\" & FileName & ".txt", 1)
      TextBuffer = TextFile.ReadAll
      if instr(textbuffer,"BUILD SUCCESSFUL")>0 then
      buildsuccess="BUILD SUCCESSFUL"
      else
      buildsuccess="BUILD FAILED"
      End If
      For i = 1 to Len(TextBuffer)
      If Mid(TextBuffer,i,1) = chr(13) Then
      Response.Write("<BR>")
      else
      Response.Write(Mid(TextBuffer,i,1))
      end if
      Next
      TextFile.Close
      FileSys.DeleteFile "d:\CodeRelease\spirituality561\CVSRoot\" & FileName & ".txt"
      Application("IsLocked")=0
      Application.Unlock()
%>
<TITLE><%=buildsuccess%></TITLE>
<BR><BR>
<CENTER>

<script>
function buildSuccessful()
     {
     answer = confirm("Build SUCCESSFUL, Deploy to Development?");

     if (answer !=0)
          {
          location = "/spirituality561/devdeployUNIX.asp?Tag=<%=Tag%>";
          }
     }
</script>

      <%if buildsuccess="BUILD SUCCESSFUL" then%>
            <script>
            buildSuccessful();
            </script>
      <%
      end if
End If 'If Application("IsLocked")=1 Then
%>


Cheers!!
0
 

Author Comment

by:boucherc
ID: 10774290
The above will lock the application, as it had before, but will not run the redirect.

A subsequent request of the application will "queue up" and run after the lock is released from the first request, instead of redirecting to the Response.Redirect page.
0
 

Author Comment

by:boucherc
ID: 10776437
I'm not sure if it makes a difference, but this page also has html code within it. Below what I tried to set up and whereever I placed the Redirect, it would not work:

<%
If Application("mbeBuild")=1 Then
Response.Redirect "/403_9.htm"
Else
%>

<html>

<body bgcolor="#000080" text="#FFFFFF" link="#FFFFFF" vlink="#FFFF9C" alink="#FFFFFF" background="bg.jpg" bgproperties="fixed">
<%
Application.Lock()
Application("mbeBuild")=1
Tag = Request("Tag")
Set FileSys = Server.CreateObject("Scripting.FileSystemObject")
FileName = FileSys.GetTempName
Set WShShell = Server.CreateObject("WScript.Shell")
IP = Request.Form("Target")
if Request("vbOption") = "no"  then
RetCode = WShShell.Run("d:\CodeRelease\mbelbh561\CVSRoot\callantbuild.cmd " & Tag & " " & "STAGING " & FileName, 1, True)
else
RetCode = WShShell.Run("d:\CodeRelease\mbelbh561\CVSRoot\callantbuildVB.cmd " & Tag & " " & "STAGING " & FileName, 1, True)
end if
Set TextFile = FileSys.OpenTextFile("d:\CodeRelease\mbelbh561\CVSRoot\" & FileName & ".txt", 1)
TextBuffer = TextFile.ReadAll
if instr(textbuffer,"BUILD SUCCESSFUL")>0 then
buildsuccess="BUILD SUCCESSFUL"
else
buildsuccess="BUILD FAILED"
End If
For i = 1 to Len(TextBuffer)
If Mid(TextBuffer,i,1) = chr(13) Then
Response.Write("<BR>")
else
Response.Write(Mid(TextBuffer,i,1))
end if
Next
TextFile.Close
FileSys.DeleteFile "d:\CodeRelease\mbelbh561\CVSRoot\" & FileName & ".txt"
%>
<TITLE><%=buildsuccess%></TITLE>
<BR><BR>
<CENTER>

<script>
function buildSuccessful()
      {
      answer = confirm("Build SUCCESSFUL, Deploy to Staging?");

      if (answer !=0)
            {
            location = "/mbelbh561/admins/stagedeploy.asp?Tag=<%=Tag%>";
            }
      }
</script>

<%if buildsuccess="BUILD SUCCESSFUL" then%>
<script>
buildSuccessful();
</script>
<%end if%>

<BR>
<A HREF=http://WEBCODE-P:81>-=HOME=-</A>
</CENTER>

<%
Application("mbeBuild")=0
Application.Unlock()
%>

</body>

</html>

<%
End If
%>
0
 

Author Comment

by:boucherc
ID: 10777548
I was able to get this to work by setting the Application to 1 before locking it:

<%
If Application("mbeBuild")=1 Then
Response.Redirect "/403_9.htm"
Else
Application("mbeBuild")=1
End If
%>

<html>

<body bgcolor="#000080" text="#FFFFFF" link="#FFFFFF" vlink="#FFFF9C" alink="#FFFFFF" background="bg.jpg" bgproperties="fixed">
<%
Application.Lock()

Since I ws pointed in the right direction, I will award the points.

Thanks for your help.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question