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
When there are more projects, would the correct configuration like this ? :
localhost:12345/ProjectName/Controller/View
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.
It shouldn't! That's why it's designed in a modular way. In most web applications out there, we version and deploy all these assemblies (Web, BLL and DAL) together. So, separating a project into 3 projects does not add any values.
You can use multiple models in a single view by creating a common model for all the models that are to be used in a single view. To achieve this, refer to the following steps. First, create a new model (common for all models) and refer all other models that are to be used in the same view.
To add a Shared Project to your existing solution, right-click on the Solution and choose "Add Project", and then select "Shared Project" from the Visual C# tab: You'll see the Shared Project appear within the Solution Explorer and from this point, you can begin adding any types of files that you want to use to it.
You can also write multiple routes onthe same action or controller. For example if you want to call Contact action method with /Home/contact url just write the [Route("home/contact")] on action method.
Can you tell me how I can do that? And how the urls would be?
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 }
);
Similarly,
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?
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
Link : How to implement it
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With