I am pretty new to mvc but have already read a few books.
What I want to archive is:
-> Having the main asp.net app in its own project.
-> Every modul (for example forum modul) is hosted in a regular dll (including its controller, models and views).
I've looked into the issue of hosting controllers in different assemblies. This is actually easy to handle. But what I do have issues with are the views.
I could not find any resource regarding how to tell mvc that he should look for the views in this namespace the the other view in the other namespace.
Best regards
Simon
Have you imported the projects/assemblies in the project you need to use them?
Look in the References folder. They must be there so you can use them.
I am not quite clear why you would use this style of architecture, but again that's your choice.
What I can confirm is that it is not going to be as useful as you think.
A detailed explanation is here
Related
I have a multi project solution for an asp.net website. There is DAL, BLL and entity projects all shared with another application and a resources project for strings (to support multiple languages).
The resource is set to public. Common.Resources is the both the project name and the namespace. Strings is the Resource file. Accessing the resources in code after referencing the project is easy
Common.Resources.Strings.[MyResourceStringNameHere]
The issue is I need to access the resource strings in the sitemap and in literal html tags doesn't work. Examples of what i have tried below.
$Resources:Strings, [MyResourceStringNameHere]
$Resources:Common.Resources.Strings, [MyResourceStringNameHere]
Much searching has led me to believe that I may need a resource manager to bring in the resources from the other project. All examples are aimed towards a SQL resource manager so aren't proving particularly helpful.
Any examples, suggestions, etc would be gratefully received.
Thanks in advance...
Here's nice example of sitemap globalization for ASP.NET Core using external resources:
Globalization in MVCSiteMapProvider
If project does not use ASP .NET Core, you can follow instructions in: https://msdn.microsoft.com/en-us/library/aa905797.aspx#exaspnet20rpm_topic5
Basically, you need to create custom ResourceProviderFactory which should return yours implementation of IResourceProvider where you can handle external resources.
We are working on ASP.NET MVC 6 project and it's necessary to load and then compile Razor views from an external source (Azure document database).
I see in other SO posts (<= MVC 5) it was possible to create and register a custom VirtualPathProvider which can take view content from DB or resource DLLs (for example).
What are the options for MVC 6 ?
Technically not implemented yet. This is after all a rewrite and not just a set of new features.
I found a thread on GitHub which talk about a way to get what you need.
Basically, it's about providing your own implementation of IFileProvider.
I have virtually no experience in implementing this but I think that if you have time to spare, this is definitely the way to go.
A bit late to the party, but if you are still looking at this I have just posted a sample project to GitHub showing how to store your .cshtml in Azure Blob storage using ASP.NET 5 / MVC 6.
#Maxime Rouiller - MVP is correct that you need to provide a custom IFileProvider. My sample is using rc1-final and working. Looking at the aspnet project though, this may change subtly later (will allow multiple providers to be registered)
A blog post write up on this should be coming in the next few days too.
I'm working in a web application that has several areas of bussiness work. With time it's size has became a problem to develop on and to maintain.
I would like to break the web project into several sub-projects or libraries depending on a main root web project that has the common files to share (Masterpages, Resources, Css, etc...)
Ideally I would like to have some kind of injection that allows me to optionally publish that "components" or simply publish a customized variation, although it's configuration depended on after deploy DB setup.
I searched all over the web, reading all the pages related to multiple projects, dependency injection and composite apps that I could find, 'till I soften my head, but couldn't find anything really useful.
Major part of the writings where a theoretical approaches or unit testing applications (well, you can't make your desired app, but you still can unit test something else)
Other approaches simply don't work in VS2010 .Net 4.0
Can someone address me on a COMPLETE solution or an example? Or simply lets discuss.
We say that the solution has the following structure, with module contents already separated into directories:
Solution
L_ Datalayer library project
L_ Bussiness logic /common utils library project
L_ Web project
L_ Controls
L_ Images
L_ Css....
L_ Warehouse
L_ Sales
Masterpages
...
Warehouse and Sales contains pages related to the "module"
Thanks,
I post my progress in the subject.
As per suggestion of Steven I experimented further more using MEF. Due to the lack of documentation, specially for webforms, that was a pain in*. So far I managed to implement MEF in my solution and sucessfully inserted a plugin project visible for the main app.
Then loads the available plugins, through an interface that has the plugin name, the default page url and its order, picks all this data and render a menu tab. That part it's easy.
Clicking on a menu element must redirect to the main page of the plugin, which will render several menus for its pages contained (from another export interface)
I finally got an aspx page embedded as a resource in the plugin project. Where I'm currently stuck.
¿Is there any way to render a page embedded as a resorce on a libray using MEF or I'm forced to also use a VirtualPathProvider? ¿Hows specifically the statement to redirect to that page? I've tried several ways but no-one works (MEF and VirtualPathProvider)
I looked at zillion of articles that talk about it but all them end doing control rendering, not page. So frustrating.
Though it is not an answer to your question, I am adding it as answer due to length of my suggestion.
I suggest you look into the approach NopCommerce is following where they have extended over .net with their own framework, which supports Plugins and extensions to existing solutions. Though I definitely know that nopcommerce is an ecommerce solution but if you study it, you can modify it according to your business needs or at least it can give you a heads on for what you should adopt while designing your solution. Hope it helps.
I created an empty Visual Studio solution and added two projects: Backend(Class Library type) that will have the.edmx file for accessing information; and Frontend(ASP.Net type) that will have the database in the app_data folder.
Is this a good architectural design or is there a more proven way to organize this type of application?
Splitting the data access code into a library project is a good idea. I'm currently working on an ASP.NET project which is almost the same - I have a library class that I use to access the data, and in the other project I have my aspx pages. The only difference is that my data is in SQL Server (using entity framework to access that data via a .DBML file).
For the type of site you're building (data in the App_Data folder) it sounds like it will be a simple site which does not need to do anything too intense i.e. scaling.
Most often it depends on the size of your project, but generally I tend to separate the front-end stuff from the backend s.t. it gets reusable. So to that direction your organization is already fine.
If you want to go a step further, I'd take a look at layered application architectures. This post here may give you some insight into that and you may find some reusable elements.
Personally I don't really like the DB to reside in the "app_data" folder of the UI project (i.e. the ASP.net Web Application project). But for small apps it's fine :)
I was curious how in the typical ASP.NET MVC mentality one could build a platform that others could develop plugins for. I mean, how would those plugins look like?
Like exiting user controls for WebForms, encapsulating all layers in themselves, or three different files representing the model the view and the controller. I should develop the core of a CMS, that I'd like others to build plugins for later on. Which mentality is better for that, classic Web Forms or ASP.NET MVC?
I need developers to be able to separately build components for that. Is it possible to encapsulate the MVC directory structure in a component DLL file and then when I reference the DLL file, to be able to directly access the component's model, view, or controller as part of the general MVC structure?
The most promising component techniques have come from the guys over at lostechies.com and Mvccontrib in the form of Portable Areas. Portable Areas allows an entire MVC app to be appended onto an existing application. So its not just a UI component but also provides all the work flow and screen integration as well.
Open Forum does something like this as well. I don't know how, but it is very plug and play.
For straight up plugin architecture there is an interesting screencast and source code for Rob Connery's link text. He takes advantage of the App-Code directory to slide new plugins into place without having to edit the main site.