Click to See Complete Forum and Search --> : [RESOLVED] Detecting a Missing page


Bill Crawley
May 23rd, 2006, 10:29 AM
Hi All,

I'm using VS2003.

I have a single page ASP.NET application that is live.

In my live environment I am just going to rename the link so that the page cannot be used temporarily whilst some upgrades are performed in the background.

However in the app I just want to test that the original page loaded and if not then place a friendly page up saying that the site is currently down.

How do I do that?

My single aspx page is set as the start page. I set some variables in the Session_start of the global.asax page and I assume that this is where I need to place my test, but I dont know what to test for.

HairyMonkeyMan
May 23rd, 2006, 10:42 AM
I would just create a custom 404 error page linked into your iis :thumb:

Bill Crawley
May 23rd, 2006, 11:26 AM
unfortunately I dont have control of IIS and so have to do this via the application.

HairyMonkeyMan
May 23rd, 2006, 11:53 AM
What about a local link checker function?

Maybe something along the lines of:


' ==== App Code ====

Imports System.IO

Namespace MyNamespace
Public Class Verify
Public Shared Sub GotoLink(ByRef strLink As String)
Dim f as FileInfo = New FileInfo(strLink)
If f.Exists Then
Httpcontext.Current.Response.Redirect(strLink)
Else
Httpcontext.Current.Response.Redirect("CustomError.aspx")
End Sub
End Class
End Namespace

' ==== End App Code ====

' ==== Calling page ====

' Use a link button in your GUI,
Imports MyNamespace.Verify

Protected Sub LinkButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton.Click
GotoLink(e.CommandArgument)
End Sub

' ==== End Calling Page ====

<!-- GUI -->
<asp:LinkButton ID="LinkButton"
CommandArgument="somefile.aspx" runat="server">LinkButton</asp:LinkButton>


Hope this helps... haven't tested any of this btw. :wave:

Bill Crawley
May 24th, 2006, 04:53 AM
Thanks, I didn't use all of your code, but took a snippet and it seems to work.