2

I just started using Visual Studio and tried to duplicate a tutorial by Bob Tabor. Trying to display a HTML file using Browser connect.

Here's what I'm doing:

  1. New project
  2. Web ASP.NET Web Application
  3. Empty
  4. Add new item --> HTML page
  5. Add 'test" to to title and body
  6. Try to view in browser - get http://localhost:51962/HtmlPage1.html with no response

Browser dashboard says no connections

Added to 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>

But nothing seems to work. Could someone provide the proper steps?

I think it might be a server issue. localhost is a connection to a MySQL database called final project. BlueWater is the name of my computer. I'm able to connect to the Mysql database. I made sure I was using 4.5.2 and also that our web.config files match. Thanks again for your help. Here's a screenshot of Server Explorer:

enter image description here

DCR
  • 14,737
  • 12
  • 52
  • 115

3 Answers3

2

I tried to replicate your issue and the results were as desired. Let me add screenshots so that you can follow through. I am using Visual Studio 2015 Community on Windows 10 with 4.5.2 .NET Framework.

Starting a new project

Starting a new project

Choosing the type of project

Choosing the type of project

Adding an HTML page

Adding an HTML page

Adding test to HTML page (Clicked on Google Chrome to run the project)

Adding test to HTML page

Running the project

Running the project

My Web.config looks like this:

<?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>

Can you replicate these steps?

EDIT: DCR and I weren't able to get IISExpress to show web page. So, we decided to troubleshoot multiple areas. Here's what worked.

  • IIS Webserver was running, so we decided to leverage that (if you don't have IIS you can install it by going to Start > Control Panel > Programs > Turn Windows features on or off > choose Internet Information Services > OK).
  • We went to http://localhost and ensured that IIS welcome page was seen
  • We closed Visual Studio 2015 Community and reopened it as an administrator
  • Right click WebApplication1 project. Click Properties
  • Click Web on the left side menu
  • Start action was chosen. Ellipse (...) button was clicked and HtmlPage1.html page was selected
  • Under servers there's a dropdown. Local IIS was chosen. Project URL changed to http://localhost/WebApplication1
  • Click on create virtual directory. Successful message was noticed
  • Save the project changes
  • Press F5
  • Page appears as desired on http://localhost/WebApplication1/ URL

https://chat.stackoverflow.com/rooms/97122/discussion-between-dcr-and-zedfoxus has some more things that could help others troubleshoot similar problem.

Attempts were made to review answers from Unable to launch the IIS Express Web server source as well.

Community
  • 1
  • 1
zedfoxus
  • 35,121
  • 5
  • 64
  • 63
  • see picture added to question – DCR Dec 06 '15 at 14:26
  • Let me zip my project and upload it somewhere for you to download. You can then try downloading it and see if it runs. MySQL and hostname shouldn't be a problem. – zedfoxus Dec 06 '15 at 14:30
  • Thanks. Do I use create project from existing files? Also, browser link dashboard still shows 0 connections – DCR Dec 06 '15 at 14:57
  • I've zipped my project as-is here: http://zedfox.us/projects/stackoverflow/34073197-WebApplication1.zip (26MB). Create c:\test. Download the zip, extract it and move WebApplication1 directory to c:\test. Examine and run that project. That project does not have any connections. You should be able to see test appear on your webpage served by your localhost. Let me know the results you see and the results you expect. – zedfoxus Dec 06 '15 at 15:07
  • Thanks but I still get waiting for localhost. I notice that when I right click on BlueWater properties is grayed out. Also, when I set up the data connection to MySQL I have to use localhost as the server name. I've tried without setting up the MySQL connection but that doesn't work either. And browser link still shows 0 connections – DCR Dec 06 '15 at 15:20
  • Aha, so it seems like something is going on when Visual Studio tries to bring up local webserver. If you [have an antivirus](http://stackoverflow.com/questions/27656654/asp-net-waiting-for-localhost-forever), can you turn it off for a short time while you test? Can you turn firewall off temporarily also? – zedfoxus Dec 06 '15 at 15:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/97122/discussion-between-dcr-and-zedfoxus). – DCR Dec 06 '15 at 15:36
  • On Windows 8.1 with Visual Studio 2015 Community I selected --> New Project->Web->ASP.NET Web Application->(ASP.NET 5 Templates)Web Application. Next Run the application and I am unable to use browser link feature. In this case maybe Web.config concept is different so how to resolve it? – Vikram_ Dec 09 '15 at 14:32
  • @Vikram_ did you start Visual Studio as an administrator? If not, right click Visual Studio 2015 and run as administrator. I'd encourage you to also read through the chat DCR and I had a couple days ago. You might find some solutions there – zedfoxus Dec 09 '15 at 15:25
  • Starting Visual Studio as an administrator didn't resolve the problem. I also tried to resolve as discussed in the chat session but even in that test WebApplication same issue I faced. I see Refresh Linked Browsers (Ctrl+Alt+Enter) option disabled in new "Project" (File->New->Project->Web Application) under ASP.NET 5, but same Refresh Linked Browsers option works fine for new "Project" (File->New->Project->MVC) under ASP.NET 4.5.2. Is there something wrong with latest version? – Vikram_ Dec 09 '15 at 17:10
  • It's really had to tell. You might have to open a new question. Include screenshots and tell us what you did so that someone from SO community can help you out. If you don't receive any help for a day or so on your question, comment back to me here with @zedfoxus and I can try to help out – zedfoxus Dec 09 '15 at 17:31
0

I found the issue to be an issue with my html source and where I was placing my Scripts.Render() and Styles.Render() methods. I placed each method outside of the html tags. Looking at the source from Firefox showed me that there were some html tags that were incorrectly closed. So I placed the @Scripts.Render() methods within the body tags and the @Styles.Render() methods in the head tags and the Browser Links started working again.

Ebsan
  • 758
  • 1
  • 10
  • 33
0

For the one who is still not getting in the visual studio like i wasn't before, try the following steps which worked for me.

  • install browser-sync if not installed globally through npm refer here
  • open a command prompt in the folder where your code is residing & run following command:

    browser-sync start --files="**/*"

enter image description here

  • you will get dashboard link of browser-sync running locally. Go their and grab piece of code which needs to be embedded in the html file before body tag.

enter image description here

  • once you do that, and open your html, you will get the following message on the page & visual studio detects your browser as connected.

enter image description here

enter image description here

Don't know whether this is bug in VS or something.

Naveen Kumar G C
  • 1,332
  • 1
  • 10
  • 12