可以在ASP.NET MVC 2应用程序映射到一个子领域? [英] Can Areas in an ASP.NET MVC 2 application map to a subdomain?

查看:130
本文介绍了可以在ASP.NET MVC 2应用程序映射到一个子领域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种办法,如

movies.example.com/Theater/View/2

而不是

example.com/Movies/Theater/View/2

其中{面积=电影,控制器=剧场,行动=查看,ID = 2}

where { area = "Movies", controller = "Theater", action = "View", id = 2 }.

推荐答案

区域将不直接相关的路由,这样你的问题就变成了不支持路由子域?

Areas are not directly related to routing, so your question becomes "does routing support subdomains?"

这个问题的答案是不幸的是没有内置对这种支持。

The answer to that is unfortunately that there is no built-in support for this.

不过,好消息是,很多人都尝试过,发现定制code的成功是建立在路由顶部:

However, the good news is that many people have tried and found success with custom code that builds on top of routing:

如果你找出如何路由子域没有再与地区的区域做起来应该没有难度。转到您的域名注册情况和使用你选择里面的任何技术。区域是只是一种组合在一起的控制器和视图 - 他们没有很本质的意义ASP.NET MVC本身(他们做一点点,但不是很多)

If you figure out how to route subdomains without areas then doing it with areas should be no more difficult. Go to your area registration context and use whatever technique you choose inside there. Areas are just a way to group together controllers and views - they don't have very much intrinsic meaning to ASP.NET MVC itself (they do a little bit, but not a lot).

这篇关于可以在ASP.NET MVC 2应用程序映射到一个子领域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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