本文介绍了ASP.NET MVC中的重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

如何在 ASP.NET MVC 2 中从"http://www.website.com/ products/brand1 "开始的所有页面中实现URL重定向"http://www.website.com/产品/品牌2 "?这里的''brand1''''brand2''是参数.我知道如何在控制器中编写代码,但是在产品" 区域中有很多,因此我需要更有效的方法.

这是一个现有站点.
确实,我在一个产品"区域中有多个具有相同功能的品牌.所以我有以下链接:
http://www.website.com/products/adidas/addnewproduct
http://www.website.com/products/adidas/editproduct?id=345
http://www.website.com/products/adidas/admin/index
...
http://www.website.com/products/nike/addnewproduct
http://www.website.com/products/nike/editproduct?id=345
http://www.website.com/products/nike/admin/index

现在,我想从"adidas"重定向到"adidas_new".这意味着,当用户在浏览器中键入"http://www.website.com/products/adidas/addnewproduct"时,它将重定向到"http://www.website.com/products/adidas_new/addnewproduct"


预先感谢.

Hello everybody!

How to implement URL redirection in ASP.NET MVC 2 from all pages which start from ''http://www.website.com/products/brand1'' to ''http://www.website.com/products/brand2''? Here ''brand1'' and ''brand2'' are parameters. I know how to do it writing code in controllers but I have a lot of them in ''Products'' area therefore I need more efficient way.

This is an existing site.
Really I have one area ''Products'' where I have several brands with the same functionality. So I have the following links:
http://www.website.com/products/adidas/addnewproduct
http://www.website.com/products/adidas/editproduct?id=345
http://www.website.com/products/adidas/admin/index
...
http://www.website.com/products/nike/addnewproduct
http://www.website.com/products/nike/editproduct?id=345
http://www.website.com/products/nike/admin/index

And now I want to redirect from ''adidas'' to ''adidas_new''. It means when the user types ''http://www.website.com/products/adidas/addnewproduct'' in browser it redirects to ''http://www.website.com/products/adidas_new/addnewproduct''


Thanks in advance.

推荐答案



这篇关于ASP.NET MVC中的重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 11:04