Visual Studio localhost IIS Server Not Found - asp.net

I'm trying to run an ASP.NET webforms website that I downloaded from an FTP server, but I'm running into problems when I try to build and run the project.
When I build and run the website, it opens my browser window, but adds "www." before the localhost address and I get a server not found error. I'm able to successfully build and run other websites, so I think I must have something wrong in the web.config or website properties. Here's a screenshot of my browser window:
Visual Studio Version: 15.7.2
IS Express: 10.0.1743
I tried changing the IIS port being used in the application.config file to see if that helped, but it gets replaced by a new site tag after I edit the original one. For example if my original port is 51060 and I change it to 51065 like this:
<sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
<site name="mywebsite" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\me\Documents\mywebsite" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:51065:localhost" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
The application.config file changes to:
<sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
<site name="mywebsite" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\me\Documents\mywebsite" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:51065:localhost" />
</bindings>
</site>
<site name="mywebsite(1)" id="3">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\me\Documents\mywebsite" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:51060:localhost" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
Thanks for any help.

Right click on your web forms application project and then properties, navigate to the Web section, then look at the Servers section, and look at the Project Url that is being used, you can also mark the option Override application root URL if needed.
I hope it helps.

Related

Old WebSite in Visual Studio 2013 and IISExpress - Virtual directory

I have a WebSite (not project, WebSite) using ASP.NET Webforms, at the begining this WebSite was created using Casini (old visual studio Web Server) with "GestorAplicaciones" as virtual directory.
The start url for the application was "http://server:port/GestorAplicaciones/Default.aspx"
Now I have opened this web site on Visual Studio 2013 and running under IISExpress but I had problems with virtual directory.
My web site in applicationhost.config was:
<site name="GestorAplicaciones" id="12">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\...\GestorAplicaciones" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:10000:localhost" />
</bindings>
</site>
Searching for information about the problem I found how to create a virtual directory in IISExpress, I have to do this:
<site name="GestorAplicaciones" id="12">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Temp" />
</application>
<application path="/GestorAplicaciones" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\...\GestorAplicaciones" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:10000:localhost" />
</bindings>
</site>
This way my web site work fine with virtual directory.
However each time visual studio open the solution it change the configuration of the website in applicationhost.config, it write this again:
<site name="GestorAplicaciones" id="12">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\...\GestorAplicaciones" />
</application>
<application path="/GestorAplicaciones" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\...\GestorAplicaciones" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:10000:localhost" />
</bindings>
</site>
Then the website doesn't work and I have to change applicationhost.config each time open the solution in Visual Studio.
How to do to visual studio don't change my web site config in IIS Express??

IIS Express keeps creating website copies

I'm developing a Web API using VS2012. In order to allow my mates access the api in the same LAN, I need to modify the applicationhost.config file.
The problem is that sometimes when I modify the code and start debugging, I found that IIS Express created a copy of my application, say MyWebAPI(1), MyWebAPI(2)... Then I have to modify the applicationhost.config again.
Does anyone know in which case IIS Express will create a copy of my application?
Here is an example of what my applicationhost.config:
<site name="MyWebAPI(1)" id="15">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Example\example" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:8080:*" />
</bindings>
</site>
<site name="SunPower(2)" id="16">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Example\example" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:8080:*" />
</bindings>
</site>

How do you manage web.config files in different projects within same solution when you need shared rules?

In my solution, I have 2 projects, call them Foo and Bar. When deployed, Foo is the root site (http://mycompany.com) and Bar is a sub-directory (http://mycompany.com/sub).
When I work on them locally in IIS Express on my local machine, I need to replicate things into web.config of both projects since I work on them separately. For example, I have one of the HMTL5 Boilerplate rules for "cache busting" in my Rewrite rules:
<rewrite>
<rules>
<rule name="Cachebusting">
<match url="^(.+)\.\d+(\.(js|css|png|jpg|gif)$)" />
<action type="Rewrite" url="{R:1}{R:2}" />
</rule>
</rules>
</rewrite>
If I just leave it in the web.config for Foo, then when I work on Bar, it's not applied and I get errors since the rewrite isn't happening. So I've replicated sections into the web.config for both projects.
But when I publish the solution to Azure, I get conflicts because of the inheritance rules since the web.config for Foo is in the root.
What is the best way to manage this? I tried to search on this topic but couldn't find this exact problem described.
Update:
My applicationhost.config for IIS Express is as such:
<site name="Bar" id="3">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\Code\mycompany\Bar\Bar" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:65052:localhost" />
</bindings>
</site>
<site name="Foo" id="4">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\Code\mycompany\foo" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:50477:localhost" />
</bindings>
</site>
I tried editing it to make both apps part of the same site, with these changes but no luck. Seems to have broken everything :)
<site name="Foo" id="3">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\Code\mycompany\foo" />
</application>
<application path="/Sub" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\Code\mycompany\Bar\Bar" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:65052:localhost" />
</bindings>
</site>
Make your root site (http://mycompany.com) as a website in IIS, and your sub-directory as virtual directory in IIS.
IIS shares the Rules defined in root website ('s web.config) with the virtual directory.
Use web.debug.config and web.Release.config to manage the development and release environment difference. For more please follow this SO POST or this MSDN blog

Publish sites at custom portnumbers in windows azure?

We are trying to publish three sites in Azure, they are on ports 8080-8082.
The site on 8080 works fine, the sites on 8081 and 8082 does however not respond from the outside.
Ideas?
This is on a single role, right? Can you put your ServiceDefinition up to look at? Typically this is because you miconfigured input endpoints or the binding. Here is a trivial example that has 3 sites on 3 different ports.
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="WindowsAzureProject1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="MvcWebRole1">
<Sites>
<Site name="Web1" physicalDirectory="../pathtowebsite1">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
<Site name="Web2" physicalDirectory="../pathtowebsite2">
<Bindings>
<Binding name="Endpoint2" endpointName="Endpoint2" />
</Bindings>
</Site>
<Site name="Web2" physicalDirectory="../pathtowebsite3">
<Bindings>
<Binding name="Endpoint3" endpointName="Endpoint3" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="8080" />
<InputEndpoint name="Endpoint2" protocol="http" port="8081" />
<InputEndpoint name="Endpoint3" protocol="http" port="8082" />
</Endpoints>
</WebRole>
</ServiceDefinition>

IIS Express with Website Project, how to use inside virtual directory?

My production environment have a root, and my virtual directory will be at /brazil folder inside the root.
When I convert my website project(not web application), that works correctly with Cassini at /brazil since my website folder is brazil, IIS Express put the site at root, how can I change this?
I'm seeing similar problems with IIS Express with web applications. From what I'm seeing, IIS Express actually allows you to define a folder in the 'Project Url' field, but then when launching it generates 2 websites, one with the folder and another for the root application. Problem with this is that it is using the same folder for both which brings web.config inheritance issues.
My solution was to go edit the hosting file and change the physicalPath for the root virtual directory to an empty folder in my system
For example:
<site name="MySite1" id="1">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\VisualStudioProjects\2010\MySite1\MySite1" />
</application>
<application path="/ssd">
<virtualDirectory path="/" physicalPath="C:\VisualStudioProjects\2010\MySite1\MySite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:59473:localhost" />
<binding protocol="https" bindingInformation="*:44302:localhost" />
</bindings>
</site>
To this:
<site name="MySite1" id="1">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\TEMP\New folder" />
</application>
<application path="/ssd">
<virtualDirectory path="/" physicalPath="C:\VisualStudioProjects\2010\MySite1\MySite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:59473:localhost" />
<binding protocol="https" bindingInformation="*:44302:localhost" />
</bindings>
</site>

Resources