Asp.net

VirtualPath 在目前應用程序根目錄之外

  • October 29, 2013

背景:帶有 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 行之間添加一個空行。然後它稍後會回來。

這可能是什麼原因造成的?

我在 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/>

有關該功能的更多詳細資訊here

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

乾杯,克制

引用自:https://stackoverflow.com/questions/19669456