Click here to Skip to main content
14,734,554 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Can anyone tell me how re-direct to web site down Maintenace page in MVC3, so whenever users log in they should be re-directed to Maintenance down page, when site is down

Note :- Some users should be able to access the application for testing purpose, remaining all user should be denied access and redirected to Down page.
Authentication Used : Windows

Thanks
Vikram
Posted
Updated 6-Nov-12 13:07pm
v2

1 solution

I have not tried so not sure about App_Offline.htm way to handle it. Details here: App_Offline.htm [^]

Following is one of the ways suggested and implemented by quite a few: Implement “Down for maintenance” page[^]. It says:
You can use a catch-all route with a RouteConstraint with the IP check.
Make sure you put the offline route first.

routes.MapRoute("Offline", "{controller}/{action}/{id}",
                new
                    {
                        action = "Offline",
                        controller = "Home",
                        id = UrlParameter.Optional
                    },
                new { constraint = new OfflineRouteConstraint() });

and the constraint code:
public class OfflineRouteConstraint : IRouteConstraint
{
    public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
    {
        // return IpAddress != "1.2.3.4";
    }
}


One other way suggested: By Using: ActionFilterAttribute[^]
   
Comments
Vikramdcecse 6-Nov-12 18:08pm
   
hey thanks sandeep, i tried the app.htm it worked but one more condition
Note :- Some users should be able to access the application for testing purpose, remaining all user should be denied access and redirected to Down page.
Authentication Used : Windows
Sandeep Mewara 26-Nov-12 22:25pm
   
That sounds like authorization configuration. Read about roles and authorization.
member60 20-Nov-12 4:14am
   
my 5!
Sandeep Mewara 26-Nov-12 22:24pm
   
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900