.NET Core can't add Razor pages - visual-studio

As you can see with the images above when I go to add a new razor page instead of taking me to the razor page prompt it instead takes me to add new item and doesn't let me add a razor page. Does anyone know why this is caused? I also need to use an empty razor page for this project.

You have to make sure you have the "ASP.NET and web development" workload installed within Visual Studio.
In Visual Studio go to Tools -> Get Tools and Features...
and make sure "ASP.NET and web development" is ticked and then click Modify / Install.
I had the exact same problem and managed to fix it by following the above steps.

Related

Visual Studio 2019: How to edit menu

In Visual Studio versions prior to VS2019, .NET framework 4.7.2, if you wanted to design a MenuStrip, you just added the MenuStrip to the form and start typing the ToolStripMenuItems. Like this:
I've recently moved to VS2019, and started to use .NET 5. If I add a Menustrip, I get an empty strip, which seems not easy to edit (I colored the background of the main form, to clearly see the white menu strip)
My question is: how to add ToolStripMenuItems?
I see the little arrow on the right, and I can select Edit Items, but to add a menu that way is quite cumbersome.
If I open an old solution in VS2019, I can edit the menu as I used to do. So it's not VS2019.
If I create a new VS2019 project using an old .NET version, I can't edit the menu, so it's not the .NET version
If I copy paste InitializeComponents from an old project to a new .NET 5.0 VS209 solution I cannot edit the menu
So, how to edit the menu? Is edit items really the proper method to edit your menus from now on?
I believe that the MenuStrip editor experience difference comes down to .NET Core vs .NET Framework.
Edit: .NET 5 = .NET Core vNext
We covered MenuStrips while we were doing WinForms in my C# class and this exact question came up. .NET Framework solutions allow you to use the convenient editor as you have demonstrated. .NET Core solutions do not.
The easiest way I found to build out my MenuStrip items when in .NET Core was to click on the menu strip, then there is a property called "Items" which is a collection. In the properties pane, you can click the three dots button to bring up the Items Collection Editor:
Here you can create new ToolStripMenuItem objects to build your menu.
Possibly related post, others suggesting this is a Core vs Framework issue: MenuStrip not allowing to create menu
This issue has been fixed
in Visual Studio latest release v16.10: 05/25/2021 (https://learn.microsoft.com/en-us/visualstudio/releases/2019/release-notes). I have tested this both in net 5 (current) and net core 3.1 (LTS).
Demo:
https://youtu.be/3s55hWrHx4U
You might have used the option that says "Windows Forms App."
This is wrong. You should use "Windows Forms App(.NET Framework)." This will let you edit the menuStrip control the easy way.

Visual Studio - The key combination (ctrl+m, ctrl+c) is bound to command (Controller...) which is not currently available

I am trying to create a new asp.net MVC 4 web application, using the asp.net tutorial.
I create a new project selecting ASP.NET MVC 4 Web Application. But when I tried to add a new controller, first, I didn't find the "Controllers" folder, I created one, and when i tried to add new Controller, I couldn't find that option. I clicked Ctrl+M, Ctrl+C so i got this message: The key combination (ctrl+m, ctrl+c) is bound to command (Controller...) which is not currently available
Note that I'm using Visual Studio 2012 Premium.
Does anyone have any idea about this?
Thanks in advance :)
Could it be you didn't select the "ASP.NET MVC 4 Web Application" template when creating a new project. I just tested: the controller folder is there, even when i selected empty template.
So try this: File -> New -> Project and type in the 'Search installed Templates' searchbox "MVC 4". Select "ASP.NET MVC 4 Web Application".

How to configure Visual Studio (2010) to open aspx pages on code behind by default on double click?

The question says it all... its pretty simple, and it can be done by selecting the file and pressing F7 but I'm always double clicking accidentally and visual studio takes forever to open the design view page (even if its almost empty), but I just wanna go straight to the code.
Any tips?
I had this problem too. My solution was to change Visual Studio to open up pages in HTML view by default. Because VS doesn't need to format the page, this is MUCH quicker. You can see how to get Visual Studio to open pages in HTML view at http://www.wiseowl.co.uk/blog/s153/visual-studio-html-view.htm.
To tell Visual Studio 2010 to open files automatically in Source view,
Tools -> Options
Select the General section of the HTML Designer tab.
Choose to start pages in Source View.
Just incase Andy's link dies, the method to make Visual Studio open ASPX pages in HTML view rather than the default designer view:
Go to Tools -> Options. Select HTML Designer from the menu at left. Select "HTML View" for HTML pages, Active Server Pages and Web Form pages. Click OK.
This forces VS to open pages in HTML view, which for developers is usually the view we work in for editing ASPX templates. In addition, it addresses the original issue of this question, which is getting VS to open pages faster, since it doesn't have to render a designer view.
I think you are asking to configure VS2010 to take you to the .cs / .vb file when you double click on the aspx page, but you could also be asking about make it go to the html source view.
If you are wondering about the latter (html source view), here is a screenshot of what setting to change.
http://screencast.com/t/8UluCEUQr
I hope this helps.

Design View on SharePoint Project Visual Studio 2010

Hi I am creating an application page for SharePoint 2010
But i ran into a little issue.
First I create a Empty SharePoint Project then I added an Application Page item to the project
When i tried to add controls i am only capable of doing so in the Source View
Some one knows how to enable the design view for this type of project?
Thanks in advance.
Design view may not available for SharePoint Developers in VS.NET because NOT all dependencies (and most importantly master page and other scripts, styles used by master page) are not available to VS.NET's project environment. So VS.NET may not be able to render the page correctly.
The Design view of the designer is disabled for application pages.
You can only design the page in the Source view of the designer.
See
http://msdn.microsoft.com/en-us/library/ee231581.aspx
here is a trick for this little problem:
add a user control to your project. copy all the markup code over to this user control. design away, then copy the markup back into your application page to start refining your code to work as a sharepoint item.

Disabled "Generate Local Resource" in Visual Studio 2010 Premium

Can anyone please help me understand why the "Generate Local Resource" option is disabled in my Visual Studio 2010 (premium version)? I have a simple Website and first of all I couldn't find the option in the menu, then I figured how to show it in the menu but is's always disabled... I'm going crazy with this.
Make sure that your page is open in Page Design View.
This option is a designer-based command, and will always be disabled unless you are in the design view with your page fully loaded.
In my case (using Visual studio 2012), the option is sometimes greyed out even when in design view. To fix it, just switch to source view and back to design view again.

Resources