Hosting ASP.NET files for local network - asp.net

I am trying to set up a site that needs to be accessed by users on my local network only with IIS Express (latest version), I am able to access it through the URL http://timesheet:8080, however, none of the other networked machines are able to access it through this URL.
The <sites> section in the applicationhost.config files reads as follows:
<sites>
<site name="Final Time Planning" id="1">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="T:\Public$\Temp\Charlie\Web\Final Time Planning" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:8080:timesheet" />
</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>
I have also added 'timesheet' in my hosts file with the local ip of 127.0.0.1.
What am I doing wrong? Any suggestions greatly appreciated. If you need any more info feel free to ask.

You say:
I have also added 'timesheet' in my hosts file with the local ip of 127.0.0.1.
Have you added a line to the hosts files of all the computers attempting to access your site, pointing to your PCs IP address?
Also, you may need to enable remote requests
EDIT
Given your lack of access to hosts files/DNS configuration, I think your best bet would be to configure IIS Express to listen on any host name. Then, someone can access it either as http://yourmachinename:8080/ or http://timesheets:8080/ depending on if they can resolve timesheets.
Change your bindingInformation attribute to
bindingInformation="*:8080:"

Related

Http is not running under Visual Studio IIS Express

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

How to use this IIS Express Config in Azure (Using Virtual Directories)

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.

configure web.config to point to a rootfolder

Could you please help me configure web.config, so that IIS express resolves all URLs, beginning form my physical root folder.
For example I want all my web files in Visual Studio to have "webroot" folder:
C:/dev/myWebMvcApplication/webroot/app/index.html
Where: myWebMvcApplication is the folder for my solution, [.sln]
and webroot is a physical folder containing all my files; so that, all URLs could look like
/localhost:port/app/index.html
and not like
/localhost:port/webroot/app/index.html
As of IIS7 changing sites within your server is generally done now in the sites section of applicationHost.config.
<sites>
<site name="Blah Blah" id="1">
<application path="/" applicationPool="DefaultAppPool">
<virtualDirectory path="/" physicalPath="C:/dev/myWebMvcApplication/webroot" />
</application>
<bindings>
<binding protocol="HTTP" bindingInformation="*:80:" />
</bindings>
</site>
</sites>
I am assuming you are are talking about changing the root of your webserver so that all applications under your solution share the same base URL. Please let me know if this is an incorrect assumption.

ASP.NET virtual directory _within_ VS2008

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.

Can I programmatically define my IIS7 site-bindings (eg. foo.domain.com)?

for my IIS7 website, i've had to go into the IIS7 Services Manager and define all the bindings for the site. Works fine.
I was wondering if it's possible to do this programatically in the web.config file instead? I know you can provide a few iis7 settings in there.. wasn't sure if it's possible to also include the bindings?
eg.
http; all unassigned ip's; port 80; foo.domain.com
https; 192.168.0.2; port 443; blah.domain.com
The configuration is found in the config file of the parent applicationHost.config, however I'm not sure it can be overridden. For example in IIS Express the section you are looking for is:
<system.applicationHost>
...
<sites>
<site name="Development Web Site" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_BIN%\AppServer\empty_wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080: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="IISExpressAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
</system.applicationHost>
You could try running (sorry - I haven't tried any of these myself):
%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.applicationHost
But from a security point of view it doesn't make sense to allow web.configs to each individually mess with system.applicationHost, as one site's config could break every other site.
Look at the Microsoft.Web.Administration namespace. you can then configure and maniuplate most of IIS 7 from C# code.
there is also a utility Appcmd that allows you to manipulate almost everything in IIS 7.0. be warned that this tool has tons of options and switches. I have only used it for the most basic of tasks such as changing physical directories on applications.

Resources