Solved

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

Posted on 2004-04-06
4
410 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
  • 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

815 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now