浏览器链接无法在Visual Studio 2015社区中运行

时间:2015-12-03 18:09:16

标签: asp.net visual-studio-2015

我刚开始使用Visual Studio并试图复制Bob Tabor的教程。尝试使用浏览器连接显示HTML文件。

这就是我正在做的事情:

  1. 新项目
  2. Web ASP.NET Web应用程序
  3. 添加新项目 - > HTML页面
  4. 将'test'添加到标题和正文
  5. 尝试在浏览器中查看 - 获取http://localhost:51962/HtmlPage1.html 没有回应
  6. 浏览器信息中心表示没有连接

    已添加到web.config:

    <system.webServer>    
    <handlers>
      <add name="Browser Link for HTML" path="*.html" verb="*" 
           type="System.Web.StaticFileHandler, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
           resourceType="File" preCondition="integratedMode" />
    </handlers>
    </system.webServer>
    

    但似乎没有任何效果。有人可以提供适当的步骤吗?

    我认为这可能是服务器问题。 localhost是一个名为final项目的MySQL数据库的连接。 BlueWater是我的电脑的名称。我能够连接到Mysql数据库。我确定我使用4.5.2并且我们的web.config文件也匹配。再次感谢你的帮助。这是服务器资源管理器的屏幕截图:

    enter image description here

2 个答案:

答案 0 :(得分:2)

我尝试复制您的问题,结果符合要求。让我添加截图,以便您可以完成。我在Windows 10上使用Visual Studio 2015社区和4.5.2 .NET Framework。

开始新项目

Starting a new project

选择项目类型

Choosing the type of project

添加HTML页面

Adding an HTML page

将测试添加到HTML页面 (单击Google Chrome以运行项目)

Adding test to HTML page

运行项目

Running the project

我的Web.config看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2"/>
    <httpRuntime targetFramework="4.5.2"/>
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs"
        type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
        type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
    </compilers>
  </system.codedom>
</configuration>

你能复制这些步骤吗?

编辑:DCR,我无法让IISExpress显示网页。因此,我们决定对多个区域进行故障排除。这是有效的。

  • IIS Webserver正在运行,所以我们决定利用它(如果你don't have IIS you can install it转到开始&gt;控制面板&gt;程序&gt;打开或关闭Windows功能&gt;选择Internet信息服务&gt;确定)。
  • 我们前往http://localhost并确保看到IIS欢迎页面
  • 我们关闭了Visual Studio 2015社区并以管理员身份重新启用
  • 右键单击WebApplication1项目。单击属性
  • 点击左侧菜单中的网页
  • 选择了开始行动。单击了椭圆(...)按钮并选择了HtmlPage1.html页面
  • 在服务器下面有一个下拉列表。选择了本地IIS。项目网址已更改为http://localhost/WebApplication1
  • 点击创建虚拟目录。注意到成功的消息
  • 保存项目更改
  • 按F5
  • http://localhost/WebApplication1/网址
  • 上显示所需的网页

http://chat.stackoverflow.com/rooms/97122/discussion-between-dcr-and-zedfoxus还有一些可以帮助其他人解决类似问题的事情。

还尝试审核Unable to launch the IIS Express Web server来源的答案。

答案 1 :(得分:0)

对于仍然没有像我之前没有进入视觉工作室的人一样,尝试以下对我有用的步骤。

  • 如果未通过npm参考here
  • 全局安装,则安装浏览器同步
  • 在代码所在的文件夹中打开命令提示符&amp;运行以下命令:

    browser-sync start --files =“** / *”

enter image description here

  • 您将获得本地运行的浏览器同步的仪表板链接。去他们并获取需要在body标签之前嵌入html文件的代码片段。

enter image description here

  • 一旦你这样做,并打开你的HTML,你将在页面上得到以下消息&amp; visual studio检测到您的浏览器已连接。

enter image description here

enter image description here

不知道这是VS中的错误还是其他什么。

相关问题