我正在用新的MVC应用程序替换旧的ASP.NET WebForms应用程序。然而,我有一个问题,用户拥有指向特定页面的旧链接,我希望自动将其转换为正确的MVC路由。
旧网站:http://mysite.com/ticketsdetail.aspx?id=12345
新网站:http://mysite.com/tickets/details/12345
在MVC路由中是否有一种方法可以捕获旧URL并将其转换为新URL?
编辑:
好的,使用IIS7 URL重写进行此操作的web.config条目是:
<rewrite>
<rules>
<rule name="Ticket page redirect" stopProcessing="true">
<match url="ticketsdetail.aspx$" />
<conditions>
<add input="{QUERY_STRING}" pattern="id=(\d*)$" />
</conditions>
<action type="Redirect" url="Calls/Tickets/{C:1}" appendQueryString="false" redirectType="Temporary" />
</rule>
</rules>
</rewrite>