如何将 beta/* 重定向到 /*?
我有一个处于私人测试版的网站,现在我需要从 beta/* 重定向到 /*。 在 ASP.NET MVC 中如何做到这一点?
谢谢 * = 一切
I have site in private beta, and now I need to redirect from beta/* to /*.
How can be this done in ASP.NET MVC?
Thanks
* = everything
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一种方法是设置一个通配符路由,该路由将采用任何带有 beta 的路由并将其发送到一个操作,然后该操作会将您重定向到正确的 url:
然后在 Beta 控制器中进行重定向:
One way is to setup a wildcard route that will take any route with beta and send it to an action that will then redirect you to the correct url:
Then in the Beta controller do the redirect:
让 IIS 为您处理重写可能会更好。应用程序不应该“意识到”它是否处于测试模式。
It's probably better to have the rewriting handled by IIS for you. The application shouldn't be "aware" if it is in beta mode or not.
您可以通过定义新路由并使用
IRouteHandler
处理重定向来实现此目的。请参阅 Phil Haack 的博客:http://haacked.com/archive/2008/12/15/redirect-routes-and-other-fun-with-routing-and-lambdas.aspx
You could do this by defining a new route and using an
IRouteHandler
to handle the redirect.See Phil Haack's blog about this: http://haacked.com/archive/2008/12/15/redirect-routes-and-other-fun-with-routing-and-lambdas.aspx