Yuck
Yuck

Reputation: 50855

Add View in Browser to Context Menu

Some of my older projects which I've brought to Visual Studio 2012 only have the option to open in Page Inspector, rather than directly in an external web browser. For instance, here is what the context menu looks like when I right click it:

enter image description here

Projects that are newly created in Visual Studio 2012 add an option to View in Web Browser:

enter image description here

How can I get the same function with my older projects? I'd rather not have to recreate the project and bring over all of the code.

Upvotes: 1

Views: 681

Answers (1)

Jimmy
Jimmy

Reputation: 28396

I don't know why it would appear on some but not all projects (sounds like VS isn't identifying the project type correctly), but you could make sure it's enabled in your settings.

  1. Go to Tools -> Customize
  2. Switch to the Commands tab
  3. Select Context Menu and choose Project and Solution Context Menus | Web Item
  4. Scroll through the list and make sure View In Browser is there. If it's missing you can do Add Command, choose File for the category, then View In Browser.

However, I'm guessing that this is configured correctly since it works for some projects. By chance, are your older projects using an older version of MVC? IIRC, older versions of MVC had View In Browser blocked for the views because VS couldn't hook them up to the correct route (i.e. it didn't know that Views\Foo\Index.cshtml mapped to http://localhost:1234/Foo). I'm not aware of a workaround for this other than upgrading the version of MVC.

Upvotes: 1

Related Questions