网站维护页面MVC 3 [英] Web site Maintenance Page MVC 3
本文介绍了网站维护页面MVC 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能告诉我如何在MVC3中将网站重定向到维护页面,因此,每当用户登录时,当网站关闭时,都应将他们重定向到维护页面.
注意:-某些用户应能够出于测试目的访问该应用程序,其余所有用户应被拒绝访问并重定向到向下"页面.
使用的身份验证:Windows
谢谢
Vikram
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
推荐答案
我还没有尝试过,所以不确定App_Offline.htm的处理方式.此处的详细信息: App_Offline.htm [实施为维护而停机"页面 [ ^ ].它说:
您可以在IP校验中使用具有RouteConstraint的全部路由.
确保先放置离线路线.
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";
}
}
建议使用另一种方法:通过使用:ActionFilterAttribute [ ^ ]
One other way suggested: By Using: ActionFilterAttribute[^]
这篇关于网站维护页面MVC 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文