在一个ASP.NET MVC 5解决方案中具有单独的项目 [英] Having separate projects in one ASP.NET MVC 5 solution

查看:57
本文介绍了在一个ASP.NET MVC 5解决方案中具有单独的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个ASP.NET解决方案中有许多项目(例如20个).所有项目都将拥有自己的数据库,模型,视图和控制器. 你能告诉我我该怎么做吗?网址将如何?如果解决方案中有一个项目,则如下所示:

I want to have many projects(like 20) in one ASP.NET solution. All projects would have their own databases, models, views and controllers. Can you tell me how I can do that? And how the urls would be? If there is one project in the solution it is like this :

localhost:12345/Controller/View

localhost:12345/Controller/View

当有更多项目时,是否会像这样进行正确的配置? :

When there are more projects, would the correct configuration like this ? :

localhost:12345/ProjectName/Controller/View

localhost:12345/ProjectName/Controller/View

还有一件事,我打算使用Identity 2.0 Framework.用户一次登录是否可以登录所有项目?谢谢.

One more thing, I am planning to use Identity 2.0 Framework. Is it possible for a user to be logged in in all projects when he logs in once? Thanks.

推荐答案

你能告诉我我该怎么做吗?网址将如何?

Can you tell me how I can do that? And how the urls would be?

您的解决方案中可以有'n'个项目.您需要使用RouteConfig.cs来处理它,如果您有三个项目,分别是"Project1","Project2"和"Project3".然后您各自的路由配置将如下所示:

You can have 'n' number of projects in your solution. You need to handle it using the RouteConfig.cs where if you have three projects as 'Project1', 'Project2' and 'Project3'. Then your respective route config would be something like below:

routes.MapRoute(
    name: "Default_1",
    url: "Project1/{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);

类似地,

routes.MapRoute(
    name: "Default_2",
    url: "Project2/{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);

用户是否可以在所有项目中登录 登录一次?

Is it possible for a user to be logged in in all projects when he logs in once?

是的,这绝对是可能的. 但是开箱即用的ASP.NET Identity不支持多个应用程序.已经说过,通过

Yes, it is definetly possible. But ASP.NET Identity out of the box does not support multiple applications.Having said that it's the developers task to achieve it thru Single Sign On

链接:如何实施

希望有帮助!

这篇关于在一个ASP.NET MVC 5解决方案中具有单独的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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