简体   繁体   中英

Sharing controller and views between projects

I am trying to create a good infrastructure for my web framework I am developing I have the following structure so far

solitude.admin web project to keep the controlers and views in how do I create this one I created a class libary but see you cannot have a web.config there

solitude.core will contain all my utililties and models

solitude.framework will be the core and meat of the cms platform my quesiton is how does one create a class libary project for asp.net mvc 4.6 to allow controllers and views to be shared i addded razor to a dll but i dont think that is correct approach

solitude.mvc this will contain the front end of the site i tried the below changing project guids to allow the sharing but its not working 在此处输入图片说明

I also changed the project type guids as suggested on aricltes on so but no joy I am trying to mimic our other platforms already work to futher my understanding.

 <ProjectGuid>{152C761A-DD2E-4C1F-AF89-DFB2547A3BCA}</ProjectGuid>
    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>solitude.admin</RootNamespace>
    <AssemblyName>solitude.admin</AssemblyName>
    <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>

Another point is if I was two have two sep projects admin and web how would one tell it to go to admin if user types www.domain.com/admin but yet be two independent web projects?.

I see good the separation of concerns. But have some questions:

1.- Why not making "solitude.admin" another web app project?

2.- Why aren't you using the expected naming conventions ? That is a lot of lowercases you got there.

3.- Why would you like/need to share Controllers? Basically, there must be a

return View();

inside them.

For views, you could create some components based on parameters (which mostly, it comes to print out some HTML). You already have Shared Views but for the same project.

I totally understand you. I'm in the same situation. I suggest you take a look at AREAS. I'm still learning it, but for what I've googled, it is the proper way to share views and controllers between projects. This is one good link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM