I'm building an ASP.NET 3.5 web application. When I run the project (using Visual Studio's built-in server), it needs to be able to access a network share as a virtual directory. I can't seem to find any information about how to do this.
The network resource is very large, is updated frequently, and is used by other developers and in other projects projects--not just me and mine.
I understand that I can create an IIS virtual directory to the network path once the site is deployed, but that doesn't help me while I'm debugging.
You can't do this with the web development server. It's for debugging a single application, not one that depends on multiple virtual directories.
How does it reference the virtual directory mapped to the share? By redirecting to resources under that virtual directory? If so, then during debugging, could you just change the location it redirects to to be an IIS virtual directory?
It's now possible to have both virtual directories and sub-applications with newer versions of Visual Studio and IIS Express.
Open .vs\All\config\applicationhost.config in your text editor of choice, then navigate to the configuration/system.applicationHost/sites node.
Update the site element that corresponds to your parent application, like so:
Original:
<site name="Web" id="1">
<!-- parent application -->
<application path="/" applicationPool="Clr4IntegratedAppPool">
<!-- application root -->
<virtualDirectory path="/" physicalPath="C:\Src\Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:5706:localhost" />
<binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>
</site>
Modified:
<site name="Web" id="1">
<!-- parent application -->
<application path="/" applicationPool="Clr4IntegratedAppPool">
<!-- application root -->
<virtualDirectory path="/" physicalPath="C:\Src\Web" />
<!-- virtual directory -->
<virtualDirectory path="/DocRoot" physicalPath="C:\Src\DocRoot" />
</application>
<!-- sub-application -->
<application path="/FooBar" applicationPool="Clr4IntegratedAppPool">
<!-- application root -->
<virtualDirectory path="/" physicalPath="C:\Src\Foo Bar" />
<!-- virtual directory; shared with parent app, so must be duplicated -->
<virtualDirectory path="/DocRoot" physicalPath="C:\Src\DocRoot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:5706:localhost" />
<binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>
</site>
Save and restart IIS Express.
Related
I am experiencing a strange problem. I have an ASP.Net Web API solution project. The solution was opened and running perfectly. Then the system automatically restarted due to a pending windows update. After that when I started the solution and ran the Web API project, it only runs on https and I even cant see the http url in Show All Applications on IIS express.
While in applicationhost.config, it contains the following bindings:
<site name="BevahiorApp.API" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\Projects\BevahiorApp.API\BevahiorApp.API" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:50145:localhost" />
<binding protocol="https" bindingInformation="*:44378:localhost" />
</bindings>
</site>
and in the Project properties under Web tab
Here is my IIS Express config.
<sites>
<site name="Test.Web" id="1">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\dev\test\Test.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:56428:localhost" />
</bindings>
</site>
<site name="Test.Api" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\dev\test\Test.Api" />
</application>
<application path="/Foo" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\dev\test\Foo.Api" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:51913: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>
So what I want is a Web project (Test.Web), an API project (Test.API) and a sub API project (Foo.API).
This works locally where the Web project is available on port 56428, the API project is available on port 51913 and the sub API project is available on the same port if the /Foo prefix is used in the request.
Trying to configure azure so the Web project is deployed to http://{web}.azurewebsites.net/, and the API projects are deployed to http://{api}.azurewebsites.net/.
I accomplished this when I had just a Web project and an API project. But after adding a sub API project, all requests to the api server returns the default IIS 500 error (html page and all).
Here is my setup-
UPDATE-
I'm currently following this tutorial and just publishing through VS right now.
https://blogs.msdn.microsoft.com/tomholl/2014/09/21/deploying-multiple-virtual-directories-to-a-single-azure-website/
My API project is being deployed to the same physical space as the web project and overwriting things like the Web.config. Does this have anything to do with using the "Basic" free-mo service plan?
UPDATE UPDATE
Managed to get publishing to work through VS. I'll update if I can replicate with automated deployments
Refer to these steps to deploy app to virtual directory of a app service.
Create a virtual directory (Application settings>Virtual applications and directories)
Specify Virtual application for Azure App Service Deploy task.
I have a Azure site and have create a Virtual applications under the site:
xxx.yyy.com/test
I deploy my ASP.NET application into this directory.
But how can I have the same setup when I do debug in Visual Studio. When I hit F5 would I like to have the application "deployed" and run in localhost:5000/test, and not localhost:5000.
Why is it that you find the answer 2 sec after you post a question?
Open the applicationhost.config for the solution, it is hidden in the .vs folder.
Find the application tag. Copy and add a new application tag and change the path from / to /test. On the first application tag did I change the physicalPath to something else.
<site name="xxx.yyy" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\" />
</application>
<application path="/test" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\Project\xxx\src\xx.yy" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:5001:localhost" />
</bindings>
</site>
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??
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>