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...
Related
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.
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?
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
When I create a new template (.cshtml) in the Views folder of my Visual Studio solution it is not showing up in the backoffice.
If I create a template from the backoffice a file is created in the Views folder that I then have to add to VS as a exciting file - why don't the backoffice show the template if I create one from Visual Studio? I've tried rebuilding the project.
You can do it in 2 ways:
Create your views in umbraco backend. Then go to visual studio and click the "Show All Files" button in solution explore. Find your new views in the Views folder. Right click on each file and choose "Add file to project".
Create your views in visual studio as normal. Then go to umbraco backend and create your Templates, and give them the same name as the view in visual studio. (If your template name in umbraco is "Text Page", -your file name should be "TextPage")
As ProNation says, all templates needs a db reference.
Views/templates work differently to some of the other files like scripts and CSS because they require a reference in the database to allow you to associate them with your doctypes.
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.