namespace problem, multiple projects in single solution - asp.net-mvc

I am following example from MVC book. I was asked to create three projects in one solution ( C# Library, MVC 2 and Test). I did it by right clicking on solution name and choose 'add > new project'. Project names are:
MVCSample.Domain
MVCSample.WebUI
MVCSample.Test
It looks fine but I can not add Domain namespace into class from WebUI project. When I am writing using MVCSample. statement in controler ( class form WebUI) InteliSense prompt only .WebUI as matching ending. What did I wrong?
I am using VS 2010 pro.

It sounds like you haven't added a reference to the Domain project from the WebUI project.
Right-click on the WebUI project in Solution Explorer, pick Add Reference and then choose the Domain project.

Related

Unable to add Razor view to project

I can't add razor view to MVC 5 project in Visual Studio 2017.
There just doesn't seem to be the template
As you can see if I choose Web from template list nothing is visible and all I see is Please choose a project type.
Now this is puzzling as I've seen this related SO post & this where both of them suggest to set project type GUID in .csproj.
I do have it set and it was there (I didn't add anything)
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
Looking at the list of GUIDs it seems that the first GUID suggests that this is ASP.NET MVC 5 project.
I also checked VS2017 installation and I do have web tooling installed
Any clue what I can also try to enable adding web templates to project?
Are you trying to add a new project to a solution or a new item to a project? Its not clear in your question?
Within your project (Solution Explorer), try right click on the Views Folder, choose add, New Item and see if you can find anything there?

ASP.NET MVC and WebApi project in one solution

I have created solution with MVC and WebAPI empty projects.
The MVC one return SPA page which should communicate with WebApi project.
But when I set MVC as startup the WebApi one do not work.
How to do that?
#Edit:
Of course I want to do that:
localhost:xxxx/MVC/Index
localhost:xxxx/API/someapi
Right-click on the solution in the Solution Explorer and select "Set Startup Projects". In that dialog, set "Multiple Startup Projects" and indicate which projects represent applications you want to start automatically. In this case it would be your two web projects.
In VS.NET Solution Explorer, Right-Click your MVC Project and choose "Set as Startup Project".
For future reference, whatever project name is in bold in Solution Explorer is the startup project.
As David mentioned, your projects will be running on different ports as they should be. By default, VS.NET will use dynamic port assignment, but this behavior can be overridden on the Properties pages of each project.

Multiple projects in one solution like nopCommerce 3.5

How do I create 2 ASP.NET MVC projects in a single solution, similar to nopCommerce 3.5? The two projects would be:
Web project at http://localhost:15536
Admin project at http://localhost:15536/Admin
In NopCommerce physically there's no two project,
If you go physically you'll find the Nop.Admin project is under the Nop.Web project , and you have to create the second project and you refer to the http://localhost:15536 project in Visual studio and add the second project with add an existing project and you have to implement AreaRegistration to specify your Url in this second project and of corse your dll have to be generated under /bin of the first project.
Best Regards

How do I add a source controlled (tfs) project to a solution and maintain binding?

I would like to create three separate ASP.NET MVC solutions, all pointing to the same Model project. How do I keep changes made from one solution update the others?
Ex, is there is way in Visual Studio to "Add new project from Source Control" like you can with a whole solution?
So you are hoping to have 3 solutions that share a common project.
You can achieve this in 2 ways.
NuGet
Have the project in it's own solution and create a NuGet package of the output, your other solutions can then consume the NuGet Package.
Shared Project
A shared project is easy to do, just ensure that your shared project is available in the same workspace as your solutions.Do a get latest, You can then just right click on the solution and choose add existing project.
Any changes you make will need to be checked back into source control, these changes will then appear in each 'copy' of the project in each of the different solutions.
The shared project works fine, but you may have to make some considerations when you come to building the solutions, the main one being that if you only make a change to the shared project would you want all of the solutions that consume it to be built on check-in?

Missing MVC templates in existing web project

In an existing VS2008 SP1 web project I'm introducing an MVC page. I was able to manually create a view and get it working just fine but I'm unable to get the "Add View" and "Add Controller" to work from the Solutions Explorer. Also, the MVC templates don't show up when I try and Add a New Item.
I know my VS2008 is setup properly because on a new project everything works fine (MVC templates show up in Web Items) and the "Add View" and "Add Controller" work fine as well. Is there a trick to get my legacy project to see these options.
I tried look around the csproj files. Nothing obvious there.
I see the template zip files in my folder ...Common7\IDE\ItemTemplates\CSharp\Web\MVC
Thanks.
My guess is that the project type is probably set wrong. I know it did change after one of the betas.
Try this: First, check in your existing files to source control, in case you accidentally mess up the project file. Open both of the *.csproj files (the one that "works" and the one that "doesn't") as text. You will have to unload the projects in the IDE in order to do this. Copy the <ProjectTypeGuids> value from the one that "works" to the one that "doesn't". Now reload the projects. See if that fixes the problem.

Resources