Virtual Directory in Azure Web Role - directory

Is there a way to create a Virtual Directory in Azure web role. I know you can create them programmaticly on a normal instance of IIS 7, but you have to assign a physical path. How is that possible in Azure?

Edit your .csdef and add VirtualDirectory node inside Site node
<WebRole name="SampleWebApp">
<Sites>
<Site name="SampleSite" physicalDirectory="..\SampleWebApp">
...
<VirtualDirectory name="Styles"
physicalDirectory="..\SampleWebApp\Styles" />
</VirtualApplication>
...
</Site>
</Sites>
...
</WebRole>
More: How to Configure the Virtual Directory Location

Have a look at this Multiple Websites in a Web Role

No. Web roles on windows azure do not support the concept of a virtual directory.

Related

how to publish two different asp.net web application into singe website using IIS 7

I am new to IIS server. I have two different asp.net web application project example client project and admin project. when i try to publish this two application seperatly configured working fine.
but I need
client project ---> localhost:9999 or www.test.com
admin project ---> localhost:9999/admin or www.test.com/admin
if it's possible mean please tell step by step
1.You need to create a website and create binding
<bindings>
<binding protocol="http" bindingInformation="*:9999:" />
<binding protocol="http" bindingInformation="*:80:www.test.com" />
</bindings>
2.You need to register www.test.com in hosts files
C:\Windows\System32\drivers\etc\hosts. Or you need to register it to DNS.
127.0.0.1 www.test.com
3.Create a virtual application under your website with name admin
https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/application/
4.Publish your client project to the root folder of your website
https://learn.microsoft.com/en-us/visualstudio/deployment/tutorial-import-publish-settings-iis?view=vs-2019
5.Publish your admin project to the application localhost/admin.
6.Grant permission for your application pool identity(IIS Apppool\apppoolname) and authenticated user like IUSR.
7.Try to access the applications.
Since virtual application are isolated from your root application, you don't have to afraid of application conflicts.

VS 2015: Binding a WebApp to something besides localhost

I've got an VS WebApp I am testing (An OData Provider if it matters). The client is Android.
You can't run the server and client (via a simulator of the client' OS) on the same box.
So I'm using a physical Android device to run the client. Unfortunately Visual Studio is hell bent on binding the webapp to (and only to) localhost. It isn't won't respond to attempts to connect to the hostname or IP address, and any attempt to change the IIS configuration inside of Visual Studio meets with an error message saying you specifically must use localhost (which obviously cannot be used to connect to from a another machine)
1) How do I get around this?
and
2) If this isn't obvious to find, how are people are expected to test from a remote device on their development machine?
JoeHz,
You need to change the binding configuration of your IIS Express for your WebApp.
In the folder where your *.sln is, find the hidden folder named .vs. Then open the xml file applicationhost.config in the config folder.
In the applicationhost.config file, find the sites nodes, then the site you want to configure.
For example:
<site name="MySiteName" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\MyDirecctory" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:8381:localhost" />
<!--Add new binding here with ip address-->
<binding protocol="http" bindingInformation="*:8381:192.168.0.10" />
<!--or add new binding with machine name-->
<binding protocol="http" bindingInformation="*:8381:MachineName" />
</bindings>
</site>
Once the file saved, make sure your IIS Express is closed and start your website. Once IIS Express started, check if the new binding worked, you should see something like this:
Ensure you can access the website in your web browser, not with localhost, but this time with your new binding like http://192.168.0.56:33617.
If all is good, then go to your Firewall, and add a new TCP rule for the port you need to open
When done, at that point any device on the same network should be able to access the website. Try the new address on your Android device web browser.
Your Android client should now be able to access your WebApp.

VS 2013 / IIS Express - serve site from localhost:port/myapp instead of localhost:port

In prod my site (mvc5) is hosted on https://company.no/myApp/ where myApp is an Application on IIS.
In dev my site is hosted on IIS Express on http://localhost:54307/
As this causes some truble with server relative paths I would like to also do my debugging on http://localhost:54307/myApp.
This is what I've tried:
Setting project url in property pages to http://localhost:54307/myApp and clicking Create Virtual directory
Tried the override application root with or without the myApp url.
Tried modify the applicationhost.config. Currently my setting looks like this:
<site name="MyApp.Web-Site" id="38">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\OP\MyApp\Main\src\MyApp.Web" />
</application>
<application path="/MyApp" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\OP\MyApp\Main\src\MyApp.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:54307:localhost" />
<binding protocol="https" bindingInformation="*:44307:localhost" />
</bindings>
</site>
When I try to open page from the myApp folder I get the follownig error:
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x800700b7
Config Error Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'WSFederationAuthenticationModule'
Config File \\?\C:\Projects\OP\MyApp\Main\src\MyApp.Web\web.config
Requested URL http://localhost:54307/MyApp
Physical Path C:\Projects\OP\MyApp\Main\src\MyApp.Web
That indicates web.config loaded twice. Any idea what I'm doing wrong?
Thanks for any help
Larsi
I hear you with IIS Express causing problems with server relative paths. You can set this up with a couple steps that don't include manually editing your applicationhost.config. I try to avoid editing the applicationhost.config manually, it seems to cause more problems than it solves. I would remove the website from your local IIS to clear out any of that stuff and then do the steps below:
right-click on your web project and select properties.
Click on the "Web" menu
change the dropdown to Local IIS and enter the URL you would like the app to resolve to then click create virtual directory, save the file and build.
You can still debug without the port number, the debugger will just attach to this new website in your local IIS instance as long as you have a debugger option checked on the web tab.
open your local IIS and make any other configurations that are required for your app to run (Authentication, Application Pools, etc.).
open your browser and navigate to http://localhost/YourAppName
since this is a website as far as your local iis is concerned, you can hit it anytime in a browser without needed Visual Studio running.

Application's AppPool permisions on parent Site folder structure

ApplicationHost.config Context
<!-- App Pool -->
<add name="Site - Intranet" autoStart="true" managedRuntimeVersion="v4.0" />
<add name="App - App1" autoStart="true" managedRuntimeVersion="v4.0" />
<add name="App - App2" autoStart="true" managedRuntimeVersion="v2.0" />
<!-- Site -->
<site name="Intranet" id="1" serverAutoStart="true">
<application path="/" applicationPool="Site - Intranet">
<virtualDirectory path="/" physicalPath="D:\Web\Sites\Intranet" />
</application>
<application path="/Apps/App1" applicationPool="Application - App1">
<virtualDirectory path="/" physicalPath="D:\Web\Apps\App1" />
</application>
<application path="/Apps/App2" applicationPool="Application - App2">
<virtualDirectory path="/" physicalPath="D:\Web\Apps\App2" />
</application>
</site>
As you can see, I have one Site with its own 4.0 CLR app pool and identity, which hosts two separate Applications, each with their own app pools and identities. All three are sandboxed into separate file system locations.
NTFS Permissions for AppPoolIdentity Accounts
Permissions must be given to each AppPoolIdentity on its respective folder (ex. IIS AppPool\Site - Intranet needs Read/Execute permissions on D:\Web\Sites\Intranet).
At this point, Application App1 should not be able to read/execute files in it's parent Site's physical folder structure. And vice versa, the hosting Site Intranet should not be able to read/execute files within App1's physical folder structure. Am I understanding that right?
When I visit a child application (ex http://intranet/apps/app1) I get a server error stating that it cannot read the parent Site's web.config file due to insufficient permissions.
If I grant the Application's identity account read/execute permissions on the parent Site's physical folder structure (ex. IIS AppPool\App - App1 access to D:\Web\Sites\Intranet) the issue is resolved.
Question(s)
Why does the child Application need to read web.config or any other files from the parent site?
Note: My parent site's web.config is already breaking child app/vdir inheritance using the <location path="." inheritInChildApplications="false"> technique.
Given that this identity account has by nature Write permissions on many folders - IIS AppPoolIdentity and file system write access permissions - doesn't this introduce a security risk? For instance, couldn't any child application now potentially write to the parent Site's App_Data folder or elsewhere?
For #1, child folders/apps inherit the web.config settings of their parent folders by default. I would assume that ASP.NET doesn't check your element before trying to access those parent web.config files. Makes sense to me though it's not what you would want.
For #2, not too sure there. If your app pool identity is a member of users (as your references answer states) then it does have read access to lots of places, but not write to too many. I wouldn't go by what the questioner says there. Not sure about the child writing to parent folders. You should be able to block that with appropriate file system permissions (keeping in mind whatever groups your app pool identity is a member of). I've never had this config so I'm not sure.

MVC area and virtual folders

I'd like the ability to add a sub "folder" to an MVC area. For instance, I have an area
~/areas/Support
And, in some classic ASP code, I need to refer to an include file
<!-- #include virtual="/Support/_inc/myinclude.asp"-->
Just for grins I tried including a virtual folder /support that points to this virtual folder, but that, of course, overrides the MVC route and keeps the MVC stuff from executing.
Suggestions?
I've found a solution that seems somewhat unconventional, but is working so far.
Under my test environment (IIS7.5 on Win7 Ultimate 64, ASP.NET MVC2), I edited the config file
c:\windows\system32\inetsrv\config\applicationHost.config
and added virtual folders like so
<virtualDirectory path="/Support/_inc" physicalPath="C:\websites\virt\...\support\_inc" />
<virtualDirectory path="/support/man" physicalPath="c:\websites\http\...\support\man" />
<virtualDirectory path="/support/man/docs" physicalPath="c:\websites\virt\...\support\man\docs" />
<virtualDirectory path="/Support/docs" physicalPath="C:\websites\virt\...\support\docs" />
<virtualDirectory path="/Support/man/_inc" physicalPath="C:\websites\virt\...\support\man\_inc" />
since there is no virtual folder (or real folder, for that matter) at /support, MVC routes that to the /Areas/Support... items. Anything that matches the virtual folders in the application config, however, seem to be routed by IIS before ASP.NET takes over, so they are correctly handled by ASP.
Interesting.

Resources