ASP.NET MVC中的URL重定向
我在一个网站上工作,该网站以前是用ASP.NET Web窗体构建的,现在是用ASP.NET MVC构建的.
I was working on a Website which was earlier built with ASP.NET Web Forms and now is built with ASP.NET MVC.
我们上周发布了新的MVC版本.
We made the new MVC version live last week.
但是旧的登录URL为 www.website.com/login.aspx 却已被许多用户标记为书签,他们仍在使用该URL,因此会出现404错误
But the old login url which is www.website.com/login.aspx has been bookmarked by many users and they still use that and hence they get 404 errors.
因此,我想知道哪种方法是将用户从旧url重定向到新的mvc url的最简单和最佳方法,而新的mvc url是 www.website.com/account/login
So I was wondering which would be the easiest and best way to redirect the user from the old url to the new mvc url which is www.website.com/account/login
像此登录URL一样,我希望用户也可以为其他几个URL加书签,那么处理此问题的最佳方法是什么?
Like this login url, I am expecting the users may have bookmarked few other urls also, so what will be the best way to handle this ?
您可以使用 URL Rewrite module
在IIS中.只需在您的<system.webServer>
部分中放置以下规则即可:
You could use the URL Rewrite module
in IIS. It's as simple as putting the following rule in your <system.webServer>
section:
<system.webServer>
<rewrite>
<rules>
<rule name="Login page redirect" stopProcessing="true">
<match url="login.aspx" />
<action type="Redirect" redirectType="Permanent" url="account/login" />
</rule>
</rules>
</rewrite>
...
</system.webServer>
该模块非常强大,允许您进行任何类型的重写和重定向.这是其他 sample rules
.
The module is very powerful and allows you any kind of rewrites and redirects. Here are some other sample rules
.