I am developing a multi tenancy web app in .NET 6. I have so far got to a point where my main app will have all the default controllers, views, view components etc.
I have also got a separate class library per tenant where I can override view components etc, my app is finding the tenant specific view component fine, but when it tries to return the view from another one of the tenants which is registered, probably because I have registered multiple assemblies with embedded view components which all have the same path.
What direction should I be looking into to make this tenant aware and to find the correct view?
If you need anything more specific let me know I'll add in the comments / update the question.
Related
I'm working on a School project and I just started working on the presentation layer.
I want to use the rolemanager that asp.net provides to limit certain pages and elements to certain groups of users.
Now when making the database for everything I already took account for making a table for my users which contains a role,username and password variable.
Now I'm trying to find a way to link these so that I can still use the role limiting functions
My project is in ASP.NET using .NET Framework
Greetings
I'm wanting to test ASP.NET MVC for a new project. One of the requirements is not allowing users to register themselves. When I select individual accounts in the MVC project type, it does not allow for the elimination of the registration option.
Is it possible to create an individual account project without the user registration portion? Do I need to roll my own custom classes? If so, what? I've looked for similar answers, but cannot find any without an already deep discussion and assumption that I am already familiar with libraries involved.
Thank you for any help.
I currently have a visual basic console application that runs on the server nightly and that has several classes. Each class has lots of properties as well as quite a few procedures and functions doing various tasks.
I have a payer class that handles information and functions dealing with payers, a recipient class that handles information and functions dealing with recipients and I have a payment class that holds information about payments. Two of the payment class properties are of payer type and recipient type. Part of my application creates a PDF out of all of this information and faxes it to the recipient.
Now I also have a asp.net website that displays information about all of these payers, recipients, and payments. Currently it does not access anything the console application has. It just gets information from the database and displays it in various list views and things.
The client is now asking to have a button on the website that would allow them to recreate the pdf that the console application currently generates. There is a lot of code involved in this and I need a way to not duplicate it.
My thought was to make a webservice that handles creating the pdf and both the application and the website could call it. But the web service will need access to these custom classes that currently live in my console application.
What would be the best way for both my webservice and the console application to have access to these classes. Would it then be possible to pass a custom object of type payment as a parameter to the webservice?
Using a class library
I had a similar situation where I had to share some classes and functions between projects. What I did was to create a Class Library and put those classes there. Also, when I created the library I had some issues with namespaces so I had some rewriting to do on that part.
So, essentially my solution was separated in two projects
The core library (class library)
The website (ASP.NET web application)
In the core library I had all code regarding the Data Access Layer, all the entity classes of my application and a bunch of helper classes, tools etc while in the website I did not leave much code except from the code involved in the pages and user controls.
With this approach you will have an extra .dll file containing the shared classes that the console application, the webservice and the web application will share.
Keep in mind that there are some things that you need to keep in mind such as the connection string where each application might store it in a different place. Also you cannot use the Request, Response, Server etc namespaces in your library since it will be null in the case of the desktop application.
Using linked files
An other way to share code between projects is to have the code files in one project and link those files to the other.
Right click in your project and choose Add -> Existing item, and then click the down arrow next to the Add button and select Add as link:
Finally this thread is about this subject, so it might be useful.
I'm looking to create a new MVC site, and one of the key problems I'm trying to solve is sharing code between a public area (web-facing) and an internal area.
Basically we have two applications, one that is the public web site that users access, and another that will be used internally at our company to view some of the same information that is also visible on the public site.
I would want to keep them as two separate sites (projects) because we have different teams of people working on each, and because we want to use different authentication formats (Forms for the public, Windows for the internal).
However, we also want to be able to share some of the code (views, controllers) between the two sites. How could we set up these two MVC sites such that one MVC site could reference a view and / or controller in another project?
For instance, we will have a view that will enable internal users to see transaction history of our public site users. If we have created that controller/view in the internal site and later we wanted to add the in the public site, how could we re-use this same view on the public site?
Technically, as others have already said, you can put everything you want shared in a class library project, and then reference this project from your other projects. Views are a bit different as, in order to share them between projects, you will have to compile them. You'll need Razor Generator for that.
Practically, though, it's going to be rare that a view should be shared between projects (aside from something like a layout), and virtually non-existent that you should share a controller. If the overlap is that great, it's an argument that the two projects should not in fact be two projects, but one. Controllers and views are so customized to the application that sharing them just doesn't make sense most of the time. It is however a very good idea to share your models and other classes.
2 approaches I can think of:
First option is to use MVC Area. It gives you different controller/view for each area, while sharing the same Model. You can also encapsulate common methods in a Helper class.
Second option, create 3 projects. One is a .NET library containing the common logic, Models, validations, sending emails etc. Then create 2 more MVC projects, one for each site, and reference the project.
Look at using Areas within your site (this would allow you to keep the projects independent, but together as one final solution). Also, look at compiling your views in another library so you can share them between projects.
Some references:
Compiling views in MVC
See also RazorGenerator
MVC pluggable modules
I am developing a multi-tenant application based on ASP.Net MVC. Depending on the user setup, the site needs to redirect to a separate module/area for that user. Each area has uses some common services, however the site's look and feel and navigation are completely different for each area/ module. Models are also overridden from a base library and we need separate teams to develop the modules (which includes controllers, views and models).
We are considering dependency injection tools such as Unity or Ninject for the same. Question is how do we inject complete module/area inside a main web site. Controllers and Models part is well understood. What is not clear is how to develop Views so that correct views are searched and used.
UPDATE
We need to develop this application with different teams. Each team will develop a module per sub-site/ area. There is a business layer which provides common services, framework and workflows. MVC is primarily a presentation layer. Each team develops a sub-site per customer using specific branding for that customer. As we add more customers, we need to add more sites. We could have used themes etc. However, the customers have different screens and different set of fields per screen. All these fields capture similar data however, the end users are in different roles to capture the data. E.g. The front office person captures varying no. of fields per customer and back end person completes the remainder. Similarly there could be more than one users facing customer's customers (visitors). There is a common component which is used for managing the visitors flow, front end desks in each office session etc. Question is how do we independently develop the MVC sub-sites and bring them under a common site using dependency injection. Specially the views. Is deployment script the only option?
From what I understand.
Your goal is to use Dependency Injection with something like Ninject so that you can inject different implementations based on the Controller in a particular area being used in your application?
If this is the case, you can setup NinjectModules that bind certain implementations of a particular service defined by your interface or abstract class through the Ninject Named attribute, which you can place on your Controller Constructors.
For example, you might have a general Search Controller that is open to the public in an area such as
http://example.com/users/home/search
Using Ninject Named Attribute you could inject an implementation of a ISearchService which is consumed by that controller, which may offer a limited amount of functionality for public users to search properties on,
however in another area of the site, such as admin or users who post their own properties on the site may get more access through the search functionality
http://example.com/tenants/home/search
This HomeController can have a different injected implementation of the ISearchService which is passed through its constructor.
Just ensure to load all your NinjectModules in Global.asax
This can be found under the Ninject Contextual Bindings documentation here
I'm going on very little information from what you've given me here, you may get better answers if you provide a little more context / code examples of the issue you are facing with your architectural design considerations.