redirect entire website in .net?

S

Stimp

I need to take my website offline for an hour or so while I perform some
maintenance... is it possible to create a 'catch-all' redirect to a
temporary page (i.e. something in Web.config or global.asax.vb) ?

People access my site through several different pages, so I couldn't put
a redirect on the homepage, and taking my server offline is out the
question.

Thanks,
Peter
 
B

bcutting

Point the default document to another place such as SiteDown.htm
instead of Default.aspx. If you want all pages that are referenced to
go there as well delete the entire directory tree and set the 404 Page
not found to the SiteDown.htm as well. You can do all this by right
clicking on the virtual directory in the iis console.

Endo
 
J

Jeff Sheldon

You can do this rather simply in IIS.

Select Properties of the web application
Goto Virtual Directory Tab
Change radio button to say "A redirection to a URL"
and put in the URL.

If you don't have access to IIS, you could just stick it in Global.asax.vb
in session:

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect("page.aspx")
End Sub
 
J

Juan T. Llibre

If you're using ASP.NET 2.0, all you have to do is place
a file named "app_offline.htm" in your application root directory.

As soon as you do that, ASP.NET 2.0 will shut-down the application,
unload the application domain, and stop processing any new requests
for that application.

ASP.NET will then respond to all requests for the application's
by returning the content of the app_offline.htm file.

If you're using ASP.NET 1.1, what I'd do is unload the application
( in the IIS Manager ), and eliminate the application;s virtual directory.

Then, create a new virtual directory with a default.aspx file
with your "Under Cobstruction" information.

When you're done, dump the under construction app
and reinstate your standard application.

If you have everything prepared, it shgouldn't take
you more than 30 seconds to make the switch.
 
S

Stimp

Point the default document to another place such as SiteDown.htm
instead of Default.aspx. If you want all pages that are referenced to
go there as well delete the entire directory tree and set the 404 Page
not found to the SiteDown.htm as well. You can do all this by right
clicking on the virtual directory in the iis console.

unfortunately I'm using a shared hosting account, so I can't get access
to IIS.

If I contact the support desk to do it, it could be 5 hours before they
respond to put the site back live.

Ah well, I'll write a redirect on every page so.

Thanks.
 
S

Stimp

You can do this rather simply in IIS.

Select Properties of the web application
Goto Virtual Directory Tab
Change radio button to say "A redirection to a URL"
and put in the URL.

If you don't have access to IIS, you could just stick it in Global.asax.vb
in session:

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect("page.aspx")
End Sub


that sounds like what I'm looking for. Thanks!
 
J

Juan T. Llibre

Very neat solution. Thanks!

I like that!
Although I like the ASP.NET 2.0 solution even more.

;-)





Jeff Sheldon said:
You can do this rather simply in IIS.

Select Properties of the web application
Goto Virtual Directory Tab
Change radio button to say "A redirection to a URL"
and put in the URL.

If you don't have access to IIS, you could just stick it in Global.asax.vb in session:

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect("page.aspx")
End Sub
 
G

Guest

Another cute way to do this would be to alter the web.config file to deny all
and use the loginUrl to Sitedown.aspx (or something like that). Doesn't even
require a recompilation:

=-=-=-=-
<!-- AUTHENTICATION
This section sets the authentication policies of the application. Possible
modes are "Windows", "Forms", "Passport" and "None"
-->
<authentication mode="Forms">
<forms loginUrl="sitedown.aspx" protection="All" timeout="30">
</forms>
</authentication>

<authorization>
<deny users="*" />
</authorization>
=-=-=-=-

(I hope this shows up right, I'm still getting used to when you have to use
special characters or not).
 
J

Juan T. Llibre

Good idea, Brian.

I assune you would *not* include login textboxes in sitedown.aspx.

;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top