35

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?

Lucas
  • 17,277
  • 5
  • 45
  • 40
Ken VeArd
  • 495
  • 1
  • 5
  • 8

4 Answers4

88

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

Crocked
  • 1,192
  • 10
  • 10
  • 1
    +1 Thanks to you, I only spent 5 seconds in solving this, instead of 5 hours googling. This answer should be checked as the one. – José Ramón Dec 12 '13 at 09:52
  • 6
    +1 This was exactly what was causing the problem for me too when using Visual Studio 2013. To **disable Browser Link** simply click the Browser Link refresh arrow in the toolbar and uncheck `Enable Browser Link`. – Joseph Woodward Dec 12 '13 at 10:47
  • 2
    To disable Browser Link you may need to insert into web.config appSettings – Michael Freidgeim Dec 24 '13 at 00:24
  • Setting worked to disable browser link in my case -- I wasn't actually debugging anything, so I didn't need the setting anyways :) – bvoyelr Oct 13 '15 at 14:06
5

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

Eyad Mansour
  • 61
  • 1
  • 4
2

Ran across this and at first I did not see the where to click because I had the project running.

Here is a screenshot "Disabling browser link in visual studio 2013 seems to fix this. "

enter image description here

Tom Stickel
  • 19,633
  • 6
  • 111
  • 113
0

I had an incorrect URL in my web application project settings. Updating the setting to use the correct address in my local IIS rectified the issue for me.

The issue arose for me as I had a different virtual directory configured in IIS compared to that specified in the project properties. I also note that opening the reopening the solution automatically creates a working virtual directory automatically in IIS

p