Add View option is not available in mvc? - asp.net-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.

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?

Unable to add Controller or View

I having problem in adding controller to the Project using Visual Studio 2017. I added the option by of ADD CONTROLLER using tools/Customize/commands.
But even after that I am unable to add it. I can just make copy of a controller and edit.
But I need solution where I can add the controller directly and generate the View.
You can follow this tutorial if you are very new to this.
Generally in an MVC project in Visual Studio to add a controller just right click on Controllers folder, then Add then Controller...

Add as link intellisense for Views

I'm trying to share some views across projects by using the "Add as Link" feature in VS2015 but the linked view appears broken in VS even though it works fine on the site.
Is there a way to get features like intellisense and "go to definition" working for a linked View?
I can reproduce this with a new solution/project:
Move Home/Index.cshtml to some other folder (currently I'm using a Solution Folder but it doesn't seem to matter where I move the files)
delete Index.cshtml from Home/
from Home/ right click and "add existing item"
choose Index.cshtml from the Solution Folder but choose "Add as Link" from the button drop down
on the linked Index.cshtml choose properties "Copy to Output Directory = Copy Always"
The site will work fine but in VS2015 the view then appears broken and no intellisense works.
This would be a great way to share a view across multiple projects but if VS thinks the view is broken it makes developing a pain.
Any suggestions? Is there a better way to share views across projects?
Here's the painful way I got it to work:
Unload the solution
Create a copy of one of the projects containing the views I want to replicate. Let's call the new project [SharedItems].
Rename the .csproj file and edit the .csproj file manually and replace the old name with the new name (probably optional, but made things easier)
Load the solution and add the new project.
Delete any files you don't need.
Rename the namespaces in the new project.
Build just to make sure it's working and Intellisense is working correctly.
Delete the files you intend to link in the original projects and create links.
Installed the MSBuild.WebApplication.CopyContentLinkedFiles NuGet package on all the original projects to automatically make physical copies of the linked files.
Now I can do all my edits in the templated project without having to maintain multiple copies everywhere.
Two big downsides:
I have to build after making edits to any linked object before I can see the changes.
I have to open the actual .cshtml files in the [SharedItems] project only. Opening a linked file breaks Intellisense until you close it and open it directly. This is especially annoying with Resharper's Search Everywhere feature because it suggests linked files.

In a particular project (MVC5) I could not able to add view as well as in the existing razor view Intellsense is not working in VS 2012

One of my project build in MVC5 where I need to modify in view, but in this project I could not able to add view by right click option ( both from view folder as well as from particular controller). I copied another existing view and rename it as per my requirement, but in that view Intelsence is not working.
Can anyone suggest me any patch up missing anywhere?
Thanks in advance..
You have to modify your vs2012 asp.net-mvc-5-vs2012
Visual Studio 2012 update 4
Web Tools 2013.1

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