asp.net-mvc-2 - 更改 Visual Studio 2010 RC 中的默认浏览器

标签 asp.net-mvc-2 browser visual-studio-2010

在 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/

相关文章:

javascript - 如果是 Internet Explorer - 添加脚本

javascript - 将所有 IE6 更新到 IE8?

c# - 如何在我的安装项目中嵌入横幅图像和/或添加删除程序图标?

visual-studio-2010 - Visual Studio 2010 优化和技巧?

asp.net-mvc - 在 MVC 网站上获取 404 错误

c# - MVC2 Html.ValidationMessageFor : add htmlAttributes but keep the default message

asp.net-mvc - MVC2 : Validating User Input/Best Practices

asp.net-mvc - Asp.NET MVC ModelBinder,获取 Action 方法

image - 为什么可以显示带有 "image/jpeg"数据 URL 的 Base64 编码 PNG?

c++ - VS 2010 未检测到模板内代码的任何更改