asp.net-mvc 在 ASP.NET MVC 项目中更改 Visual Studio 默认浏览器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1032743/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change Visual Studio Default Browser in an ASP.NET MVC project
提问by Kirschstein
Firefox is set as Windows' default browser.
Firefox 被设置为 Windows 的默认浏览器。
I want to change the default browser used by Visual Studio for debugging. Normally the route I'd take to do this is right clicking on an .aspx file and setting the default from the Browse With...dialog.
我想更改 Visual Studio 用于调试的默认浏览器。通常,我采取的方法是右键单击 .aspx 文件并从Browse With...对话框中设置默认值。
Unfortunately, ASP.NET MVC Views don't have the Browse With...option.
不幸的是,ASP.NET MVC 视图没有这个Browse With...选项。


In what other ways can you set the default browser for ASP.NET MVC projects?
您还可以通过哪些其他方式为 ASP.NET MVC 项目设置默认浏览器?
Related, but NOT ASP.NET MVC specific:
Visual Studio opens the default browser instead of Internet Explorer
相关,但不是特定于 ASP.NET MVC:
Visual Studio 打开默认浏览器而不是 Internet Explorer
采纳答案by Matthew Jones
There appears to be an answer here
似乎有一个答案在这里
If you right click on any page other than default.aspx you will not get the "browse with" option.
So, when working on an ASP.NET MVC application, right click on default.aspx and chose "Browse With..." Then you'll get a dialog that will allow you to change your default browser.
如果您右键单击 default.aspx 以外的任何页面,您将不会获得“浏览方式”选项。
因此,在处理 ASP.NET MVC 应用程序时,右键单击 default.aspx 并选择“浏览方式...”,然后您将看到一个对话框,允许您更改默认浏览器。
回答by Carls Jr.
For MVC1:
对于 MVC1:
- there is a default.aspx just right click on the page and select browse with and a dialog pops out for you to set your default browser.
- 有一个 default.aspx 只需右键单击页面并选择浏览方式,就会弹出一个对话框供您设置默认浏览器。
For MVC2:
对于 MVC2:
- we need to trick the project a little bit.
There are 2 ways
1.) You can add default.aspx on the project, just right click on the project and add a new item then select MVC 2 view page and then name it default.aspx and there you can right click it and do the same steps on changing the default browser for mvc1.
2.) You can add an html page anywhere within the project and after adding it just right click and select browse with and just do the same steps on changing the default browser for mvc1.
- 我们需要稍微欺骗一下这个项目。有两种方法
1.) 您可以在项目上添加 default.aspx,只需右键单击该项目并添加一个新项目,然后选择 MVC 2 视图页面,然后将其命名为 default.aspx,然后您可以右键单击它并执行更改 mvc1 的默认浏览器的相同步骤。
2.) 您可以在项目中的任何位置添加一个 html 页面,添加后只需右键单击并选择浏览,然后执行相同的步骤更改 mvc1 的默认浏览器。
For VS2010:
对于 VS2010:
You can try this extension. It is safe, hopefully this will be added in the next releases of Visual Studio.
http://visualstudiogallery.msdn.microsoft.com/en-us/bb424812-f742-41ef-974a-cdac607df921
你可以试试这个扩展。这是安全的,希望这将添加到 Visual Studio 的下一个版本中。
http://visualstudiogallery.msdn.microsoft.com/en-us/bb424812-f742-41ef-974a-cdac607df921
回答by kbvishnu
For MVC 4.
对于 MVC 4。
select the view folder. right click , you can see the browse withoption. and select the browser you want.
选择视图文件夹。右键单击 ,您可以看到 浏览选项。并选择所需的浏览器。
EDIT
编辑
Another way, Thanks to Chris O
另一种方式,感谢Chris O
"That didn't work for me, instead I found the Browse With context menu item in another dir, App_Start, which seemed to work"
“这对我不起作用,相反,我在另一个目录中找到了 Browse With 上下文菜单项App_Start,这似乎有效”
回答by J_D
MVC 3
MVC 3
Right click on your web project that you want to view in a non IE browser, select "Debug/Start New Instance". Then go to your system tray and you will see an icon with the image of a web page and a cog in the corner. Right click the icon and select "Open in web browser". The site will open in your default browser.
右键单击要在非 IE 浏览器中查看的 Web 项目,选择“调试/启动新实例”。然后转到您的系统托盘,您将看到一个带有网页图像的图标,角落里有一个齿轮。右键单击该图标并选择“在网络浏览器中打开”。该站点将在您的默认浏览器中打开。
回答by NetStarter
In Visual Studio 2010 the default browser gets reset often (just about every time an IDE setting is changed or even after restarting Visual Studio). There is now a default browser selector extension for 2010 to help combat this:
在 Visual Studio 2010 中,默认浏览器经常重置(几乎每次 IDE 设置更改时,甚至在重新启动 Visual Studio 后)。现在有一个 2010 的默认浏览器选择器扩展来帮助解决这个问题:
WoVS Default Browser Switcher: http://visualstudiogallery.msdn.microsoft.com/en-us/bb424812-f742-41ef-974a-cdac607df921
WoVS 默认浏览器切换器:http://visualstudiogallery.msdn.microsoft.com/en-us/bb424812-f742-41ef-974a-cdac607df921
Edit: This works with ASP.NET MVC applications as well.
编辑:这也适用于 ASP.NET MVC 应用程序。
Note: One negative side effect of installing this extension is that it seems to nag to be updated about once a month. This has caused some to uninstall it because, to them, its more bothersome then the problem it fixes. Regardless it is easily updated through the extension manager and I still find it very useful.
注意:安装这个扩展的一个负面影响是它似乎每个月更新一次。这导致一些人卸载它,因为对他们来说,它比它修复的问题更麻烦。不管它通过扩展管理器很容易更新,我仍然觉得它非常有用。
You will see the following error when starting VS:
启动VS时会看到如下错误:
The Default Browser Switcher beta bits have expired. Please use the Extension Manager or visit the VS Gallery to download updated bits.
默认浏览器切换器测试版位已过期。请使用扩展管理器或访问 VS 库下载更新的位。
回答by ruffin
Might be zombie threading, but I was overcomplicating this on VS2015. You can [now?] simply select which browser should open when you hit F5 to start debugging by selecting it here, no extensions needed:
可能是僵尸线程,但我在 VS2015 上过于复杂了。您可以 [现在?] 只需在点击 F5 开始调试时选择应该打开哪个浏览器,在这里选择它,不需要扩展:
Yes, yes that doeslist Seamonkey as an option.
是的,是的,确实将 Seamonkey 列为一个选项。
回答by Slauma
For an ASP.NET MVC 2 project in Visual Studio 2010I've found that
对于Visual Studio 2010 中的ASP.NET MVC 2 项目,我发现
- you need to have an .aspxfile in the rootof the project (the folder where also global.asax and web.config is located). Having an .aspx file in any subfolder like "Views" is not sufficient.
- the name of this .aspx file doesn't matter, it isn't necessary to name it default.aspx
- 您需要在项目的根目录(也是 global.asax 和 web.config 所在的文件夹)中有一个.aspx文件。在像“Views”这样的任何子文件夹中有一个 .aspx 文件是不够的。
- 这个 .aspx 文件的名称无关紧要,没有必要将其命名为 default.aspx
Then the context menu offers a Browse with...option when right-clicking on this file in the solution explorer.
然后,在解决方案资源管理器中右键单击此文件时,上下文菜单会提供一个Browse with...选项。
回答by LeftyX
In visual studio 2010 you can use this extension: World of VS Default Browser Switcher
在 Visual Studio 2010 中,您可以使用此扩展:VS 默认浏览器切换器的世界
回答by Kiran Banda
Please use Default browser switcher extension for Visual Studio 2010. It allows you select one of the installed browsers as the default browser for that dev. session and it works for all .NET web projects.
请使用 Visual Studio 2010 的默认浏览器切换器扩展。它允许您选择已安装的浏览器之一作为该开发的默认浏览器。session 并且它适用于所有 .NET web 项目。
Steps to install this extension : Tools - > Extension manager and search for Default browser .. Select WoVS Default Browser Switcher, download and install. Restart your VS 2010 and open an mvc project. Enable the Default browser switcher tool bar and notice that it has enabled the browsers that are available on the machine.
安装此扩展的步骤:工具 -> 扩展管理器并搜索默认浏览器 .. 选择 WoVS 默认浏览器切换器,下载并安装。重新启动 VS 2010 并打开一个 mvc 项目。启用默认浏览器切换器工具栏并注意它已启用机器上可用的浏览器。
Cheers, Kiran Banda
干杯,基兰班达
回答by joe
1) Right click on a .aspx page in your solution explorer
1) 右键单击解决方案资源管理器中的 .aspx 页面
2) Select the "browse with" context menu option
2)选择“浏览方式”上下文菜单选项
3) In the dialog you can select or add a browser. If you want Firefox in the list, click "add" and point to the other browser name (ex:firefox.exe) filename
3) 在对话框中,您可以选择或添加浏览器。如果您希望 Firefox 出现在列表中,请单击“添加”并指向其他浏览器名称(例如:firefox.exe)文件名
4) Click the "Set as Default" button to make this the default browser when you run any page on the site.
4) 单击“设为默认值”按钮,使其成为您在站点上运行任何页面时的默认浏览器。

