I am developing my first web app using VS 2022 Community version. The application works wonderfully in the Studio. When I run it locally by double clicking on the "Default.aspx" page or from my local ISS Site it goes off the rails.
I am using .NET Framework 4.6.1 in the application properties. I see .NET 4.6.1 Targeting Pack installed on my Windows 10 development PC.
In my ISS Management I see only two versions of .NET in my dropdown box. .NET CLR Versions v4.0.30319 and v2.0.50727 (and "No Managed Code"). I have tried multiple .NET version in my application.
When I run locally by double clicking on the "Default.aspx", I get:
"error on line 1 at column 2: StartTag: invalid element name. Below is a rendering of the page up to the first error." and nothing at all is rendering. I will provide the DEFAULT.ASPX file and the WEB.CONFIG file below.
**DEFAULT.ASPX**
Code:
<%@ Import Namespace="Ticketing" %>
<%@ Page Title="Home Page" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="Ticketing._Default" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="jumbotron">
</div>
<div class="row">
<div class="col-md-4">
<h2>Tickets for Event 1</h2>
<p>
You can easily find a web hosting company that offers the right mix of features and price for your applications.
</p>
<p>
<a class="btn btn-default" href="HTML to API - event tickets.htm"><strong>TICKETS »</strong></a>
</p>
<p>
</p>
</div>
<h2>Zip Code Search</h2>
<p>
You can easily find a web hosting company that offers the right mix of features and price for your applications.
</p>
</div>
<p>
<asp:Button ID="cmZip" Text='Press Here after entering Zip Code' runat="server" />
<%-- --%>
<asp:TextBox ID="txtZipCode" runat="server"></asp:TextBox>
</p>
<p>
<asp:TextBox ID="txtZipResult" runat="server" Height="312px" ReadOnly="True" TextMode="MultiLine" Width="2000px" Wrap="False"></asp:TextBox>
</p>
<div class="row">
<p>
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>
</p>
</div>
</asp:Content>
**WEB.CONFIG **
Code:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.6.1" />
</system.Web>
-->
<system.web>
<customErrors mode="Off"/>
<compilation strict="false" explicit="true" targetFramework="4.6.1" debug="true"/>
<httpRuntime targetFramework="4.6.1"/>
<pages>
<namespaces>
<add namespace="System.Web.Optimization"/>
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt"/>
</controls>
</pages>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f"/>
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"/>
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
<!--ProjectGuid: CD8E53D2-B177-494B-AE08-1CEEF98E43D7-->
When I run it locally by double clicking on the "Default.aspx" page or from my local ISS Site it goes off the rails.
Because that's not how you're supposed to run it. It should be deployed to your local web server (ISS) and run from there by accessing http://localhost or what ever is the default for local web.
1, .NET CLR Versions v4.0.30319 is the correct one to select
2, It would be best to test by creating a windows server VM with IIS + .Net 4 + Asp.net components all installed to test with as this will replicate real world use at least in the longer term
3, How have you installed you website? or are you manually copying over your files, are you doing any other setup inside IIS?
4, also dont try to run your website by double clicking on the webpage, its not a windows application. Once setup correctly in IIS you should be able to just browse to it, in fact there will be a Browse button inside IIS which should launch your website.
Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you
I have my IIS Default Document set to "Default.aspx" and when I use http://localhost it says:
"The Web server is configured to not list the contents of this directory.
Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server."
If I enable directory browsing I obviously get a list of the files in my wwwroot folder.
"3, How have you installed you website? or are you manually copying over your files, are you doing any other setup inside IIS?"
I am manually copying my Publish created by the Studio. I made no other setting changes to my IIS configuration other than the Default Document.
"4, also dont try to run your website by double clicking on the webpage, its not a windows application. Once setup correctly in IIS you should be able to just browse to it, in fact there will be a Browse button inside IIS which should launch your website."
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
Most likely causes:
It is possible that a handler mapping is missing. By default, the static file handler processes all content.
The feature you are trying to use may not be installed.
The appropriate MIME map is not enabled for the Web site or application. (Warning: Do not create a MIME map for content that users should not download, such as .ASPX pages or .config files.)
If ASP.NET is not installed.
When I go to "Configuration Editor in IIS and click "Test Settings", I get
"The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, IIS Manager cannot verify whether the built-in account has access. Make sure that the application pool identity has Read access to the physical path. If this server is joined to a domain, and the application pool identity is NetworkService or LocalSystem, verify that <domain>\<computer_name>$ has Read access to the physical path. Then test these settings again."
My suggestion would be to set aside trying to publish a website from VS for now.
Create a "Hello World" style bare bones .aspx file in Notepad, place that in the root of your website, and see if you can get that page to load and display properly using a web browser when browsing to localhost/HelloWorld.aspx. If that doesn't work, then your problems are larger than anything VS related, and you've got some issues with the IIS (or whatever Microsoft calls it now) configuration on your PC.
I created a brand new project (the "ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript." default). I published, copied to my wwwroot folder and restarted the web site and am having the same issue using using link the web site link in IIS.
I used the VB 2022 default .NET of 4.7.2. I will keep plugging away.
I created a brand new project (the "ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript." default). I published, copied to my wwwroot folder and restarted the web site and am having the same issue using using link the web site link in IIS.
I used the VB 2022 default .NET of 4.7.2. I will keep plugging away.
Ok, maybe try what I suggested. Don't use VS, don't "publish" anything. Use Notepad to create an .aspx file. You don't need any code inside of it or anything, it could be as simple as:
Code:
<html>
<body>
Test
</body>
</html>
That's it. Now place that .aspx file in the root of your website folder and try to access it using a web browser and the proper path.
I found the answer. It has to do when " IIS is installed after VS or .NET framework.". Even though "Programs and Features → Turn Windows features on or off → Internet Information Services (IIS) → World Wide Web Services →
Application Development Features → " had a Full check, none of the IIS ASP components were installed. I installed ASP.NET 3.5 and 4.8 and everything is working great!