我们可以播出ASP.NET MVC .aspx扩展 [英] Can we broadcast .aspx extension in ASP.NET MVC

查看:102
本文介绍了我们可以播出ASP.NET MVC .aspx扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个令人困惑的问题。我必须转换成ASP.NET MVC的ASP.NET Web应用程序。一切都很好,但问题是,网站所有者希望这样的网页的URL应该不会改变意味着如果有任何页有一个网址 http://abc.com/a.aspx 那么它应该是因为它。
现在,我已经告诉我的队员,这是不可能播出像ASP.NET MVC的.aspx分机的任何分机,但是他告诉我要搜索。
因为我有很多做搜索,但没有发现任何方式来执行它。
是否有可能,我们可以通过播放一些路由配置在ASP.NET MVC2或3 URL .aspx扩展,使网页网址没有改变。

I have a confusing question. I have to convert an ASP.NET Web application in ASP.NET MVC. Everything is going fine but problem is that, site owner wants that urls of pages should not be change means if any page have a url http://abc.com/a.aspx then its should be as it. Now I already told my team members that it is not possible to broadcast any extension like .aspx extension in ASP.NET MVC, but he told me to search it. As I had did lot of search but did not find any way to perform it. Is it possible that we can broadcast .aspx extension in URL in ASP.NET MVC2 or 3 by some routing configuration so that page urls did not change.

任何帮助将AP preciated。

Any help will be appreciated.

推荐答案

您可以做多种方式。最简单的可能是使用IIS URL重写重写任何.aspx文件到equivelent MVC路线。

You can do this a number of ways. The easiest might be to use IIS Url Rewriting to rewrite any .aspx file to its equivelent MVC route.

一个不同的方法是简单地创建匹配.aspx扩展和路由到您的控制器/动作的路由。即:

A different way would be to simply create Routes that match a .aspx extension and route them to your Controller/Action. ie:

routes.MapRoute("Default", "{controller}/{action}.aspx",  
   new { controller = "Home", action = "Index" });

这里的缺点是,你不能使用友好的参数,也可以,但它可能会破坏现有的网址。他们会像blah.com/blah/blah.aspx/blah。当然,查询字符串参数仍然有效。

The drawback here is that you can't use friendly parameters, well you could but it would probably break an existing URL. they'd look like blah.com/blah/blah.aspx/blah. Of course querystring parameters still work.

第三种方法是简单地设置IIS重定向用的.aspx其equivelent MVC路线的任何分机。

A third way would be to simply setup IIS to redirect any extension with .aspx to its equivelent MVC route.

这篇关于我们可以播出ASP.NET MVC .aspx扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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