在 Visual Studio 2010 (RC) 中,右键单击 .aspx 页面时不再有“浏览方式”上下文菜单。您现在如何更改默认浏览器?
默认情况下,它似乎使用操作系统默认浏览器,但我更喜欢在调试 ASP.net 应用程序时使用 IE。 (我正在用 ASP.net MVC 2 测试这个)
最佳答案
在 MVC 项目中的 .aspx View 上没有“浏览方式”选项,因为它们不是可直接浏览的。
我倾向于做的是在站点的根目录中添加一个 Default.aspx 网络表单,当右键单击时,将为您提供浏览选项。你需要确保更新你的路由,否则 IIS/Cassini 会尝试提供它,就像这样
public void Page_Load(object sender, System.EventArgs e) {
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled).
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
此外,另一个快捷方式是按 CTRL-F5(无需调试即可运行),这将在不进入 Debug模式的情况下启动站点。
关于asp.net-mvc-2 - 更改 Visual Studio 2010 RC 中的默认浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2443749/