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?

2
  • Could this be because of the old School <!-- inside the script tag? I removed that and the IDE became more happy and I am not getting the error anymore.
    – Ken VeArd
    Oct 29, 2013 at 21:37
  • Don't use <!-- inside of a script tag. Use // to comment individual lines or /* */ to comment blocks.
    – dgarbacz
    Oct 31, 2013 at 13:33

4 Answers 4

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

4
  • 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. Dec 12, 2013 at 9: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. Dec 12, 2013 at 10:47
  • 2
    To disable Browser Link you may need to insert into web.config appSettings <add key="vs:EnableBrowserLink" value="false" /> Dec 24, 2013 at 0:24
  • Setting <compilation debug="false" ... /> 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, 2015 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)

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

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.