create area in MVC project - asp.net-mvc

In an MVC4 web application, what is the best way to create an Area? Can it be automated or is it a manual process of creating the controller, View folder etc?

Right click on the ASP.NET MVC project in the solution explorer and select Add Area... in the contextual menu. Then type the name of the area and proceed:

Related

Add View option is not available in mvc?

I want to add a view but that option is not seen after clicking on ActionResult, it shows only go to view option. suggest me how to do that what is happening with visual studio?
Thanks in advance.
You don't necessarily need to create the view through that method, you can just create one via clicking on the subfolder within your views folder (in the solution explorer) that has the same name as your controller (i.e. in your case, it will likely be called "CPP_Reports"). Add new item, etc.
Creating a view in MVC
If your real concern is why you can't do so using the controller ActionResult, the only thing that I can think of is make sure your project setup is correct.
For instance, in MVC 5, you need to add a new scaffolded item to your project called "MVC 5 dependencies". Perhaps there is an update pending in your Nuget Package Manager for the MVC Runtime Assemblies.
Basically You have 6 projects that is ApplicationComponent,ApplicationMapper,V3-MVC(Main Project),DataAccess,GenrateLabels and Logging,will click on main project then first unload it add the below code to csproject then reload it and done below is the whole process.
Right click on Project then Click Unload project.
Open .csproject
3.Find the code (may be different): (ProjectTypeGuids) {E3E379DF-F4C6-4180-9B81-6769533ABE47}; {349c5851-65df-11da-9384-00065b846f21}; {fae04ec0-301f-11d3-bf4b-00c04f79efbc} (ProjectTypeGuids)
4.Add the section After first Curly Braces {E3E379DF-F4C6-4180-9B81-6769533ABE47};
5.Then go to Project right click on it then again load the project and Done.

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.

"Nest Related Files" icon not available in asp.net mvc app

In Asp.Net I create ViewModels that are the models for a particular view; one viewmodel per view. Because it's a one-to-one relationship, I like keeping the ViewModel as a nested file to the view. It's very tidy this way.
In Asp.Net MVC files will appear nested most of the time. However, sometimes they become unnested. I can remedy this by cutting-and-pasting-and-renaming the files, which renests them. However, it sure would be nice to have the 'nest related files' appear in the solution explorer in Visual Studio for an MVC project.
Any ideas why that icon ("nest related files") is missing from Visual Studio? and how might I get it back?
Thanks!
You can do this with the VSCommands Extension. Take a look in the studio gallery.
The alternative is either as you have been doing - copying and pasting files, or by editing the project file directly.
Found it - check on the VSCommands feature page - it's listed as Group/Ungroup Items
http://vscommands.com/features/
To group items, in solution explorer highlight both items you want to group (parent & child), r-click the child and choose "Group Items".
To ungroup items, in solution explorer highlight the child you want to ungroup, r-click and choose "Ungroup Items".

ASP.NET MVC - "Add View" Outside of the Views Folder

Are there any changes I can make to Visual Studio to add the "Add View" dialog option to a folder other than Views? I have my website split up somewhat differently and I'd still like access to the T4 templates provided by "Add View".
To clarify:
I am not trying to change the default View Engine or do anything in code pertaining to how my Views work, I simply would like to know if there is any way to have the "Add View" context menu item display on Solution Explorer items other than just the "Views" folder. My application has an "Areas" folder which contains a "Views" sub-folder for each Area and I would like to have the "Add View" menu item available when I right click on Areas > AREANAME > Views and select "Add".
It seems this behavior is hardcoded in Microsoft Visual Studio 9.0\Common7\IDE\Microsoft.VisualStudio.Web.Extensions.dll file.
I think you could:
try reverse engineering this library;
ask MVC team members for its source code.

Resources