Virtual Directory in IIS 7.5 - asp.net

We got 2 websites (WebsiteA and WebsiteB). On WebsiteA, I chose "Add a virtual directory" and selected a folder on WebsiteB to be my physical path. The Alias is the same as the target.
As you can see, on WebsiteB, the folder "Main" is already an application.
In the forum, I saw that people with the same error forgot to convert the folder as an application, but mine is already done didn't?
I found that right clicking on my virtual directory (first image) and selecting "Convert to application" seems to work. Is it the right way to do this? By doing this, do I lose my virtual directory? I don't want to use duplicate content (if I edit something in the "Main" folder on websiteB, I don't want to edit the "Main" folder on WebsiteA manually too). I have been told to use the virtual directory as it's supposed to do the job, but none of us has used it before. Thanks

Virtual directories and applications work a little bit different in IIS > 6.0. Virtual directories used to be self contained applications in IIS 6.0, so your web.config file would be fine. But in IIS 7.0 and above, a virtual directory is just that, a pointer to a directory.
If you are looking for the same effect of a virtual directory as in IIS 6.0, you'll need to create an application underneath WebsiteA, not a virtual directory. A virtual directory in IIS 7 and above runs as a directory underneath the parent website, not as a separate application.

Related

IIS returning 404 when virtual directory has a specific name

IIS Version: 10.0.14393.0
OS: Windows Server 2016
I'm trying to access a virtual directory via IIS which is pointed to a folder that just contains a basic html page, however it's returning 404 and I'm not sure why. It seems to have to do with the specific name of the virtual directory, let's say ABC_ABC1234. At first I thought it was a folder permission issue, but I created a second virtual directory named Test, pointed it to the same folder, and the html page loads up just fine. The only difference between the two virtual directories is the name, and they are targeting the same app pool, folder, etc.
There are other virtual directories with the same naming convention and those all work. I also tried the same virtual directory name on another server, and it works just fine. I didn't see anything out of the ordinary in the event viewer logs or in the IIS logs. I compared the entries in the applicationHost.config file and they are identical except for the name. I've tried IIS resets, server restarts, deleting and recreating the virtual directory, all to no avail.
I am pretty much out of ideas at this point. Any help or suggestions on what would cause this would be much appreciated!

Errors after add Virtual Directory in IIS

My web service on IIS can work well w/o a virtual directory (called by http://localhost). However, I want to call it like http://localhost/virtualpath.
So I added a virtual directory in IIS, but when I explorer website, it gives me the following error:
What does this mean and how to solve it? (I'm using IIS 8.5)
It means exactly what the error says - you've tried to set a section in web config beyond application level. I'm assuming that you added the virtual directory under a pre existing website in IIS? What you want is to add a physical directory under the website with your app in and then simply right click and convert that folder to an application.

the element 'buildProviders' cannot be defined below the application level

I have created an asp.net C# application developed in visual studio 2010, which is running without any error on my PC, but when i tried to run the same application on another computer with visual studio 2010, it gives following error,
The element 'buildProviders' cannot be defined below the application level.
Following article at http://forums.iis.net/t/1160248.aspx?The+element+buildProviders+cannot+be+defined+below+the+application+level+
You probably need to convert the virtual directory to application. I encountered this when deploying my app (using NancyFX).
You can open IIS Manager->Right-click the diretory of your web application->Click Convert to Application.
I faced this problem and i found out that somehow i had another version of my website within the subfolders of my webstie.
Meaning that my website is in a folder called "FrontEnd". Withing this folder there is a subforlder called backup that contains a backup of my website.
when i removed the backup folder, everything went ok.
If you recently upgraded your solution, check for the backup directory for crystal report within your solution. The backup directory can get created when you upgrade visual studio. To resolve this error, closed the solution. Went to the solution directory
and delete or move the backup directory to a different location outside of the solution directory. This solved the problem for me
You can fix this problem either defining the element in the web.config file of the root dir or setting Virtual Directory as APPLICATION in IIS.
For doing this with IIS 6.0, you first have to set the the directory in which your site is present as a Virtual Directory and then define this virtual directory as an Application.
All physical directories under Inetpub\Wwwroot are not considered applications until the following procedure is used:
Open IIS Manager.
Expand the Default Web Site node and look for the subdirectory that you want to designate as an application root.
Right-click the directory that you want to mark as an application root, and then click Properties.
On the Directory tab, in the Application Settings section, click Create.
In the Application name text box, type the name of the application, and then click OK.
The virtual directory is now an application root.
Maybe on oppening website you were selected upper project directory as website root
In my case, the issue was that the web.config inadvertently existed in a subfolder of the applications root folder. I had a "temp" subfolder, and I had placed a copy of the web.config there, unaware of the unintended side effects. The solution in my case was to remove the dup copy in the subfolder. Hth
(In my case name of project was repeating in directory )
The problem's solution is very simple: check its root directory in Solution Explorer. If there is a name folder within another name folder then this error will occur. Your web site contents should be very first after your web site name folder. In other words, contents should not display in another same name folder.

why it is still necessary to create virtual directory in IIS when website content is placed in IIS root directory

As virutal directory points to physical path of the application, so if the IIS root directory is C:\inetpub\wwwroot and the application is stored at D:\websites, than we need to create a virtual directory but if the application content is placed at C:\inetpub\wwwroot, then why still need to create virtual directory.
Actually you don't need to create a virtual directory. What you need to do is define it as an application folder, adding a virtual directory does this by default so that's why it works. All you really need to do is right click the folder under your website, click properties and under the Application Settings section click create. Your folder will then have a gear icon off to the side denoting it as an application folder.
As to why application folders are necessary, I believe it's a way of forcing you to choose which Application Pool you want the application running in rather than having every sub directory application running off the same pool by default.
IIS isn't used just for ASP.Net, it can serve up PHP for example...so the type of application and pool varies, it's not automatically created and tied to then ASP.Net engine.
If you can clarify a bit more what you're trying to do maybe we can help further. For example, if you want to point the root application to another folder and it be an application or create another website, IIS allows you to do any of that...you just need to update the question with which version of IIS, as the instructions very between them.
If the IIS site will host a single ASP.NET application you can place it at the root (C:\inetpub\wwwroot) and you don't need to create a virtual directory because when you create the site it is already a virtual directory.

Virtual directory deleted when publishing asp.net application?

A short question.
I have a website running at :80.
I create a virtual directory "itemimages" under the site that reference E:\itemimages.
When i publish the ASP.net to the website at :80 with "Delete all existing files prior to publish" the virtual directory "itemimages" is also deleted.
Any way to stop this from happening?
Or better: Any way to define the virtual directory inside the asp.net application so i will be created in any "fresh" publish?
Thanks in advance!
Try publishing the website to the directory, as opposed to the website? I.e. publish to c:\Websites\WebsiteRoot (or whatever the path is), as opposed to http://www.sitename.com/
Or you could try using the "Replace files" instead of deleting all preexisting files ?

Resources