Weird but not Wonderful - .Net Core project discovery
-
Using Visual Studio 2019: When I write code for an article, I write the article in an html file that lives in the project itself. As I progress, I eventually want to see what the article looks like in the browser. In .Net Framework projects, this works fine, but in .Net Core projects (in this instance, it was a .Net Core 3.1 project), the menu item "View in browser" does not exist in the context menu for the file. Why would that be?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Using Visual Studio 2019: When I write code for an article, I write the article in an html file that lives in the project itself. As I progress, I eventually want to see what the article looks like in the browser. In .Net Framework projects, this works fine, but in .Net Core projects (in this instance, it was a .Net Core 3.1 project), the menu item "View in browser" does not exist in the context menu for the file. Why would that be?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013This is interesting. I created a VStudio 2019 -- ASP.NET Core project. I added a basic.html page to the project in the Views\Home\ folder. I do have the context menu item "View in browser (firefox)". However, when I attempt to load the page it loads the URL in my browser but doesn't display the page (probably due to routing issue). The URL in the browser looks like : http://localhost:49464/Home/basic which is incorrect. It should have the .html. Also I do have UseStaticFiles() in my startup.cs. EDIT I moved the .html file out to the root (not under views) and now I have the context menu item in 2019 and it actually loads the page now. It was a routing issue in the previous attempt.
-
This is interesting. I created a VStudio 2019 -- ASP.NET Core project. I added a basic.html page to the project in the Views\Home\ folder. I do have the context menu item "View in browser (firefox)". However, when I attempt to load the page it loads the URL in my browser but doesn't display the page (probably due to routing issue). The URL in the browser looks like : http://localhost:49464/Home/basic which is incorrect. It should have the .html. Also I do have UseStaticFiles() in my startup.cs. EDIT I moved the .html file out to the root (not under views) and now I have the context menu item in 2019 and it actually loads the page now. It was a routing issue in the previous attempt.
Mine is a Core 3.1 project. I wonder if that makes a difference...
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Mine is a Core 3.1 project. I wonder if that makes a difference...
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Not sure... Here's a snapshot of my Project...[ProjectName] Properties... https://i.stack.imgur.com/gKeTO.png[^] Is this what yours looks like? My project is named WebAppCore
Mine isn't a web app - it's WPF. EDIT ============ I don't see anything in your settings that's different from mine, excpet mine says "Windows Application" where yours says "Console Application".
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Mine isn't a web app - it's WPF. EDIT ============ I don't see anything in your settings that's different from mine, excpet mine says "Windows Application" where yours says "Console Application".
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013Well, this only took me 24 hours to respond... But anyways, you are correct if it is a WPF app you won't see that context menu. Check this snapshot out -- top of Visual Studio : https://i.stack.imgur.com/ozTUB.png[^] Whether it is wrong or right Studio removes the contextual stuff related to web server and web browser when the app isn't a web project. Compare that first one to this one (which was my previuos web app) See the IIS Express choice at the top ==> https://i.stack.imgur.com/sCewp.png[^] . Not great, but just the way VStudio works I think.
-
Using Visual Studio 2019: When I write code for an article, I write the article in an html file that lives in the project itself. As I progress, I eventually want to see what the article looks like in the browser. In .Net Framework projects, this works fine, but in .Net Core projects (in this instance, it was a .Net Core 3.1 project), the menu item "View in browser" does not exist in the context menu for the file. Why would that be?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013Does the behavior change if you mark the file "Build action: None", or exclude from project? That might be sufficient to tell Studio to display it using the default browser rather than something dependent on what the rest of the project is doing.
Software Zen:
delete this;
-
Using Visual Studio 2019: When I write code for an article, I write the article in an html file that lives in the project itself. As I progress, I eventually want to see what the article looks like in the browser. In .Net Framework projects, this works fine, but in .Net Core projects (in this instance, it was a .Net Core 3.1 project), the menu item "View in browser" does not exist in the context menu for the file. Why would that be?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013..who's fault it is now?.. ..the one who loaded the gun?.. ..or the one who pulled the trigger?.. 🤏🤏🤏🤏