Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VirtualPath was outside the current application root

Background: ASP.NET Webforms Application with VB.NET backend.

I just recently upgraded from Visual Studio 2010 to Visual Studio 2013 and .NET 4.5.1. This code used to work since we were on Visual Studio 2005 and .NET 2.0. But since the upgrade I am getting this error.

In a ASCX User Control.

<script language="javascript" type="text/javascript"> <!-- function SetItem_<%Response.Write(m_strJSAlias)%>(strValue) {      $("#<%Response.Write(txtShop.ClientID)%>").attr('value',strValue);     __doPostBack('frmCorpPortal_Form','');     void FocusOnNext_<%response.Write(m_strJSAlias)%>; } 

We now get this error that we never got before:

VirtualPath was outside the current application root. Parameter name: virtualPath  Description: An unhandled exception occurred during the execution of the current web request.    Please review the stack trace for more information about the error and where it originated in the code.   Exception Details: System.ArgumentException: VirtualPath was outside the current application root. Parameter name: virtualPath   Line 4:  <script language="javascript" type="text/javascript"> Line 5:  <!-- Line 6:  function SetItem_<%Response.Write(m_strJSAlias)%>(strValue) { Line 7:       $("#<%Response.Write(txtShop.ClientID)%>").attr('value',strValue); Line 8:      __doPostBack('frmCorpPortal_Form',''); 

If I play with the file and make a nonsensical change, the error goes away. Example: add a blank line between Line 4 and 5. Then it comes back later.

What could be causing this?

like image 423
Ken VeArd Avatar asked Oct 29 '13 21:10

Ken VeArd


2 Answers

I had the same issue with an old app in iis and when running from visual studio. Disabling browser link in visual studio 2013 seems to fix this. This feature injects some javascript into your page and causes this problem for me at least. Since I disabled it now it works in IIS and from Visual studio.

http://techatplay.wordpress.com/2013/10/24/vs2013-asp-net-application-error-virtualpath-was-outside-the-current-application-root/

Some more details on the feature here

http://blogs.msdn.com/b/webdev/archive/2013/06/28/browser-link-feature-in-visual-studio-preview-2013.aspx

Cheers, Crocked

like image 121
Crocked Avatar answered Oct 11 '22 07:10

Crocked


Disabling browser link in visual studio 2013 fixed this in my case, just uncheck the "Enable Browser Link" in vs (near the Run button)

like image 31
Eyad Mansour Avatar answered Oct 11 '22 07:10

Eyad Mansour