ASP.NET Virtual Path Maps To Another Application Which Is Not Allowed

I have a website that was building without any issue on multiple servers.
But, when I copy/move it on the same machine from one folder to another folder: I started getting the error

The Virtual Path Maps To Another Application Which Is Not Allowed.

What am I doing wrong?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

The source of this problem is that when one copies an ASP.NET Web Site to a new folder — the properties setting associated with the solution “Virtual Path” is set to the folder name and not the root. The solution is to change the Virtual Path setting from the folder name to “/”.

This can be found by right click the project and opening the properties dialog: Solution->Properties->Virtual Path-> Change to “/”

Method 2

This isn’t why your error happened but it may be useful to someone researching the problem who ends up here.

If your web app is running as an application within another IIS site (set via the IIS administration tool) and is attempting to reach resources of the other site by means such as HttpResponse.Redirect, make sure the project isn’t set to use a separate IIS in Visual Studio. If it is, it may be firing up inside a different IIS than the rest of the site.

Method 3

Additional check: Missing global.asax also causes the same error.

Method 4

If you are creating a new HttpContext and calling any external
service, it also causes the same error.

Key is you should not create new HttpContext, change the existing
context to your needs.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x