VirtualPath在当前应用程序根目录之外

时间:2013-10-29 21:25:41

标签: asp.net webforms visual-studio-2013 browser-link

背景: 使用VB.NET后端的ASP.NET Webforms应用程序。

我刚刚从Visual Studio 2010升级到Visual Studio 2013和.NET 4.5.1。此代码以前用于Visual Studio 2005和.NET 2.0。但是自升级以来我遇到了这个错误。

在ASCX用户控件中。

<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)%>;
}

我们现在得到了以前从未有过的错误:

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','');

如果我使用该文件并进行无意义的更改,则错误消失。示例:在第4行和第5行之间添加一个空行。然后它稍后返回。

导致这种情况的原因是什么?

4 个答案:

答案 0 :(得分:88)

我在iis中使用旧应用程序以及从visual studio运行时遇到了同样的问题。在visual studio 2013中禁用浏览器链接似乎解决了这个问题。此功能会将一些javascript注入您的页面,至少会对我造成这个问题。因为我现在禁用它,它可以在IIS和Visual Studio中使用。

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

有关此功能的更多详细信息

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

干杯, 喝醉

答案 1 :(得分:5)

在Visual Studio 2013中禁用浏览器链接修复此问题,只需取消选中vs中的“启用浏览器链接”(在“运行”按钮附近)

答案 2 :(得分:2)

跑过这个,起初我没有看到点击的位置,因为我让项目运行。

这是截图 “在visual studio 2013中禁用浏览器链接似乎解决了这个问题。”

enter image description here

答案 3 :(得分:0)

我的网络应用程序项目设置中的URL不正确。更新设置以在我的本地IIS中使用正确的地址为我纠正了这个问题。

问题出现了,因为我在IIS中配置了与项目属性中指定的虚拟目录不同的虚拟目录。我还注意到,打开重新打开解决方案会自动在IIS中自动创建一个可用的虚拟目录

P