Multi domains for one project or multi domains for multi projects - model-view-controller

I'm planning to make the graduate project about the e-commerce site using ASP.Net Core 2 MVC and SQL Server, but currently, I have some troubles:
Suppose I have two domain and sub-domain: domain.com and manage.domain.com. The domain.com will like the normal e-commerce site which allows customer go to browse, search, and buy the products. The manage.domain.com will only for staff to log in and do their stuff like manage staff, order, etc.
My questions are:
Is there possible to manage two domains on one MVC project or I have to split them up? If it is possible, then how can I manage it just in one MVC project?
If I have to split them up to two projects: one for e-commerce, one for staff, then should I create the WebAPI to connect as a data layer to communicate the projects with the same database as the suggestion of Sagar Shirke?
Are there any other approaches to my problems? Any comments and idea will be very very appreciated.
Thanks for reading my problems!

After thinking about this some more I think you are taking the wrong approach.
Why don't you look at using a premade framework with an admin template page to manage typical admin task (users, passwords, custom data, etc.) ?
Instead of using a subdomain like sub-domain: domain.com, you could use domain.com/admin.
Here is an link to ASP.NET Boilerplate templates. I would recommend you look at the simple todo task examples and see if this is concept is what you want. Using the free Module Zero admin page templates to develop quickly. I would make sure you do the tutorials and read the documentation.

This is a great tutorial on how to use subdomains.

Related

3 MVC projects in 1 Solution

I have to build 3 MVC web applications using Entity Framework (www.company1.com www.company2.com www.company3.com). The websites will all access the same sql server database, but will be slightly different in their own way (appearance, data etc). More than likely all three MVC applications will be hosted on the same server, but binded to different domain names.
Currently in Visual Studio, I have the following structure to my solution
Domain Classes
Data Layer
Services
Repositories
MVC App 1
MVC App 2
MVC App 3
I would have preferred to have used Area's, but I can't because each site has to be assigned it's own different domain name. I guess I am just seeking assurances that architecting my solution this way won't cause any difficulties for me when the applications are published. I am slightly paranoid about the sites sharing the dbContext or something, however, I know that many sound silly.
It would be great if anyone could advice me if this all looks ok, or maybe there is a better way to do what I am asking.
Thanks as ever.
I've done the same thing for the same reason. I have a CMS that must reside at a different host-name. It works fine.
The trick is finding ways of sharing code across the MVC apps. To avoid circular dependencies and such, I created one more MVC app to hold things such as my controller that serves up image files, HTML Helpers that can be re-used, etc.
As long as you have a good way of validating and differentiating the sites in the Datalayer, than you will not have to worry. How are you validating this?
I also would always put simulair code and pages in a main project so you do not copy parts or even whole pages for different sites. (My guess is that you already did so)

Possible to use one codebase for a subdomain for multiple sites?

I don't even know if this is even possible, but I thought I'd ask.
I am creating a small CRUD application but I have multiple sites. Each site would use the CRUD. The application would have common CRUD methods and style, but each individual site would apply different forms. I want to avoid creating multiple CRUD applications that varied only in specific content (just different forms).
I want to have something like this:
mycrud.website1.com
mycrud.website2.com
mycrud.website3.com
I can create a subdomain for each individual site no problem. But is it feasible to point all the subdomains to one MVC application directory? And if it is possible any suggestions for how I might go about restricting users from website1 from seeing website2 or website3 content? Is that something "roles" could take care of (after authenticating user)?
Thanks.
There are a lot of websites that do this, not just with MVC. Some content farms point *.mydomain.com to a single IP and have a wild card mapping in IIS.
From there, your application should look at the URL to determine what it should be doing. Some CMS systems operate in this manner, using the domain as a key to deciding what pages to load.
I've built a private labelable SAS application (Software as a Service) that allows us to host all of our clients in a single application. Some clients have customizations to pages or features. We are able to handle that by creating custom plugins for each client that over-ride the Controllers or Views when needed.
All clients share a common code base and aside from each clients custom theme/template they are the same. Only when a client had us customize one feature did we need to build out their plugin DLL. Now, this is advanced stuff so it would require heavy modifications to your code base but in the end if it's what your application needs it is 100% possible.
First - the easy part is having one web site for all three domains. You can do that simply with DNS entries. No problem. All three domains should point at the same ip.
As far as the content, you could do that in a number of ways. I think your idea of roles is pretty solid. It also leaves open the possible of a given user seeing content from both site1 and site2, if that would ever be necessary.
If you don't want to force users to authenticate, you should look at other options. You could wrap your CRUD logic and data access logic into separate libraries and use them across three different sites in IIS. You could have one site and display content based on the request URL. There's probably a lot of other options too.

Advise needed - which Rapid Application Development Framework using PHP and MVC meets this specific need?

we are a parents initiative who runs a small kindergarden / child nursery and we set out to build a basic web based documentation and reporting application for our nursery.
After spending a week doing research on the various PHP MVC frameworks, I have a few questions that I could not answer myself - even after having a closer look (installed on local machine) at CakePHP, Symfony, CodeIgniter, YII and Joomla.
The goal is to build a web application where site managers, staff and parents (roles) can log in to do simple tasks, depending on their role (hence I need a RBAC). Site managers will for example be able to add staff to the database, staff will be able to add children and do some documenation on children (select a child and enter details on special needs etc.). Parents should be able to update information about who is picking up the child, or inform the staff if a child will not come in at a certain date.
Now, since this is all basic CRUD with only a few tables underneath, tables connected via some foreign key constraints, I would like the framework to generate CRUD skeletons for me.
And since I need to manage roles and limit access to certain pages, I would like a basic user management out of the box.
Plus, PHP and MySQL and MVC are set - otherwise I would have used Oracle Apex as I have some experience with that.
So, I looked at a vast amount of PHP frameworks and found the following to be promising:
CodeIgniter (with Bonfire plugin)
Symfony2
YII framework with GII
CakePHP
Joomla
BUT none of the frameworks I looked at seemed to fit my need:
creating CRUD skeleton pages based on my ERD with foreign keys (MySQL InnoDB) / Scaffolding
offering a basic user management out of the box with up to date security measures in place (passwords stored using phpass or salted hashes & md5, user registration, defining roles and limiting tasks to roles/users).
If somebody could suggest a PHP Framework that comes with those two requirements build in, I would be very happy to hear about it. THANK YOU very much in advance!!
(I really liked CodeIgniter because it was simple to set up and lightweight, I liked the Bonfire user management plugin but was disappointed when I found out they sacked scaffolding in the lasted release
And I liked Joomla for its user management, but found it quite hard to get started on component development, plus no scaffolding).
You should check FuelPHP and its ORM, Oil and Auth packages. It's really great. If you liked CodeIgniter, you'll probably love Fuel.
http://www.fuelphp.com

Getting own EF 4.1 Code First classes to work with .NET Membership

I am working on a simple web application that is built with EF 4.1 Code First and MVC3. My Domain Model sits in a project outside the MVC3 project.
I have gotten to the stage where my web application is more or less complete. However right now, my application doesn't have any form of authorization or authentication. So a regular user can get to Actions and Controllers that only an Admin is suppose to have access to.
My question is, how do I get my web application to work with the .NET Membership ? Because I am aware that the .NET Membership has many database tables of its own !
My knowledge is fairly limited, thus any clear, easy to follow responses would be greatly appreciated.
After the Membership is set up, I know my way around applying Authentication and Authorization to Actions and Controllers.
Thank You.
Go into your C:\Windows\Microsoft.NET\Framework\v2.xx or v4.xx\ and execute aspnet_regsql, this will launch a wizard that allows you to choose your database and it will add the stored procs and tables to allow membership to function.
Then you run the ASP.NET configuration wizard (the little toolbox icon at the top of your solution explorer) and then configure your roles and accounts. See this page and skip to the Configuring the website for membership and roles section.
ASP.Net membership is actually kinda interesting and frustrating to an extent. To you run a tool called aspnet_regsql.exe found in your Windows\Microsoft.net\Framework folder which generates all of the necessary tables to get it running. Next move onto your Web.config file. If you started with your basic ASP.NET MVC 3 template then you should have a <connectionStrings> entry under the name "ApplicationServices". Change that to your database connection string. This is what the membership provider uses to hook everything up. If you look through the rest of the config file there should be sections for <authentication>, <membership>, <profile>, and <roleManager>. These deal with the various sections and settings that the ASP.Net user management is broken into.
At this point everything should be hooked up. If you select your project in the solution explorer, a little red hammer icon should appear. This is the ASP.NET configuration manager. You can use this to set up different profiles and manage different users.
Now this stuff won't be connected to your EF4.1 code first stuff at all. Instead, you can interact with your membership provider through static classes Membership and Roles. If you take a look at the AccountController on a default ASP.Net MVC 3 Internet application template it will give you a good idea how it works.
After working with this stuff for several months, I found it much easier to basically write your own. Tying things together eventually becomes a huge pain and there is a whole lot of extras that the membership provider gives you that is unnecessary for small applications.

CodeIgniter - where to put CMS

I come from a background of coding my client website projects from scratch with MySQL and PHP. They are typically public facing sites with a mixture of static content, dynamic content plus a little functionality here and there (i.e. account, searching etc). Nothing too heavy.
So I generally code up a little CMS site to let them update what they need to, put it in a protected folder and that's that.
Now I'd like to use CodeIgniter and more of a MVC approach for my next site. Should I be doing anything to separate the CMS out from the rest of the site or is it simply another area (with its own controllers/models etc) and extra authentication?
There are several good methods to create an admin interface in CodeIgniter described at:
http://philsturgeon.co.uk/news/2009/07/Create-an-Admin-panel-with-CodeIgniter
You probably will want to look mostly at "#2" on his list; it's lightweight and not much additional work.
The CMS is part of the site, if by CMS you mean administration panel / backend of your application, you can use the above link provided by coreylink as it details different ways to create an admin panel.
My personal preference is to create a folder called 'admin' in my controllers directory and create semantically meaningful names so my urls are webapp.com/admin/users and so on.

Resources