如何Homepage.aspx重定向到一个MVC默认路由? [英] How to redirect Homepage.aspx to an MVC default route?

查看:265
本文介绍了如何Homepage.aspx重定向到一个MVC默认路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个新的系统,以取代现有的系统。

We're developing a new system to replace an existing system.

新系统ASP.NET MVC因此我们定义路由我们的控制器和动作是正常的。

The new system is ASP.NET MVC so we're defining routes to our controllers and actions as normal.

旧系统作为传统的ASP.NET这样的URL包括大量的.aspx页面中。

The old system as traditional ASP.NET so the URLs consist of lots of .aspx pages.

我们希望,这样当用户试图访问设置重定向 /Homepage.aspx (很多用户都会有一个书签的),他们会重定向到新系统的默认路由,这仅仅是 /

We want to set up redirects so that when a user tries to access /Homepage.aspx (lots of users would have that bookmarked), they'll get redirected to the new system's default route, which is just /

什么是我做这件事的最佳方式?

What is the best way for me to do this?

编辑: @Chance建议下面我指定的路线:

edit: @Chance suggested below that I specify the route:

routes.MapRoute(主页,Homepage.aspx,新{控制器=控制器,行动=主页});

这工作,但我希望做一个重定向,因为我不想让 Homepage.aspx 在地址栏中。还有什么我能做什么?

This works, but I'd like to do a redirect because I don't want Homepage.aspx in the address bar. Is there anything else I can do?

推荐答案

您可以看看的的以下博客帖子这说明了如何可以实现一个传统的路由处理程序将执行301永久重定向。

You may take a look at the following blog post which illustrates how you could implement a legacy route handler which will perform 301 permanent redirects.

这篇关于如何Homepage.aspx重定向到一个MVC默认路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆