背景资料: 具有VB.NET后端的ASP.NET WebForms应用程序.

我最近刚从Visual Studio2010升级到Visual Studio2013和.NET 4.5.1.自从我们使用Visual Studio2005和.NET2.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/

这里有更多关于该功能的详细信息

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

干杯, 坏了

Asp.net相关问答推荐

缓存httpmessage内容

如何在没有 Select 按钮的情况下在 GridView 中实现全行 Select ?

如何使图像的一部分成为可点击的链接

返回值使用 String result=Command.ExecuteScalar() 结果返回 null 时发生错误

Httpclient 该实例已经启动了一个或多个请求.只能在发送第一个请求之前修改属性

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

如何从 JS 访问 ViewBag

如何在asp.net mvc的html.actionlink中调用javascript函数?

System.Web.MVC 自 MS14-059 以来未复制到 bin 文件夹中.如何防止由于 Windows 更新而创建缺少 DLL 的构建?

MVC 3视图中的当前上下文中不存在名称'HTML'

如何将枚举类型绑定到 DropDownList?

在生产中使用 LocalDb 是否正常?

当.NET抛出WebException((400)错误请求)时如何处理WebResponse?

会话存储在客户端还是服务器端

在 C# 中动态创建 Json

如何在 .NET Core 中实现 DbContext 连接字符串?

如何将列表转换为数据表

LinkBut​​ton 向 OnClick 后面的代码发送值

将 HTML 字符串转换为图像

强制 IIS Express 进入classic 管道模式