2

I am getting The request was aborted: The connection was closed unexpectedly error when trying to read the helper methods.

Below is the code from the Index.cshtml

@Helper.InsufficientRightsDataBoundScript(!user.HasAccessToBuisnesses, "Insufficient rights to view this page.")

helper.cs

@helper InsufficientRightsDataBoundScript(bool noAccessToRecords, string defaultMessage, string methodSuffix = "")
{
    <script language="javascript">
        @{
            var x = "function OnDataBound"+ (string.IsNullOrEmpty(methodSuffix) ? string.Empty : "_") + methodSuffix+"(e) {";
            @x;
        }

        var grid = e.sender;
        if (grid.dataSource.total() === 0) {

            var filter = grid.dataSource.filter();
            var msg = (filter && filter.filters.length > 0) ? "No rows match the filter criteria." : "@defaultMessage";
            var colCount = grid.columns.length;
            if (@noAccessToRecords.ToString().ToLower() === true)
                msg = "No Businesses Exist.";
            $(e.sender.wrapper)
                .find('tbody')
                .append('<tr class="kendo-data-row"><td colspan="' + colCount + '"><div class="alert alert-danger">' + msg + '</div></td></tr>');
            }
        }

    </script>
}

Below is the full stacktrace

The request was aborted: The connection was closed unexpectedly. 
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.Net.WebException: The request was aborted: The connection was closed unexpectedly.

Source Error: 


[No relevant source lines]

Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\984a967f\ceba3ee6\App_Code.6rfuon9f.1.cs    Line: 0 

Stack Trace: 


[WebException: The request was aborted: The connection was closed unexpectedly.]
   System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state) +6926936
   System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32 size) +118
   System.IO.BinaryWriter.Write(Int32 value) +73
   Microsoft.WebTools.BrowserLink.Runtime.Tracing.MappingDataWriter.WriteBeginContext(Int32 sourceStartPosition, Int32 sourceLength, Boolean isLiteral, String sourceFilePath, Int32 renderedOutputIndex, Int32 renderedPosition) +81
   Microsoft.WebTools.BrowserLink.Runtime.Tracing.DataDispatchExecutionListener.BeginContext(PageExecutionContext context) +127
   CallSite.Target(Closure , CallSite , Object , Object ) +199
   System.Web.WebPages.Instrumentation.PageExecutionListenerAdapter.BeginContext(PageExecutionContextAdapter context) +184
   System.Web.WebPages.Instrumentation.InstrumentationService.BeginContext(HttpContextBase context, String virtualPath, TextWriter writer, Int32 startPosition, Int32 length, Boolean isLiteral) +160
   System.Web.WebPages.HelperPage.BeginContext(TextWriter writer, String virtualPath, Int32 startPosition, Int32 length, Boolean isLiteral) +105
   ASP.<>c__DisplayClassb.<InsufficientRightsDataBoundScript>b__a(TextWriter __razor_helper_writer) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\984a967f\ceba3ee6\App_Code.6rfuon9f.1.cs:0
   System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +10
   System.Web.WebPages.WebPageBase.Write(HelperResult result) +80
   ASP._Page_Views_businesses_Index_cshtml.Execute() in d:\Source\OLT\Feature\Nv.Tax.OLT\Views\Businesses\Index.cshtml:86
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105
   System.Web.WebPages.StartPage.RunPage() +17
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +64
   System.Web.WebPages.StartPage.RunPage() +17
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +64
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +256
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +52
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9849569
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +50
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +163

I have currently tried the following: - Delete %TEMP% - Delete C:\Windows\Temp - Clean build - Delete IIS Site and redo it - Delete the project solution and get a fresh copy from the source control

I have not seen anything like this before, so I'm a little lost at the moment. Any help or suggestions would be greatly appreciated.

  • I have the same problem. Did you find a solution? – NickG Oct 18 '19 at 13:29
  • i think I solved this issue, but the solution makes no sense at all. Basically I switched to Visual Studio 2017 from 2019 and the problem went away. – Yervand Mazlumyan Oct 19 '19 at 14:19
  • 1
    I have the same issue, seems that is caused because the browser link https://developercommunity.visualstudio.com/content/problem/809919/browserlink-and-razor-helper-the-request-was-abort.html I disabled the browser link as a work around – vfabre Dec 19 '19 at 13:37
  • @vfabre the same for me. I guess you should create a specific answer, for easier future references. – T-moty Jan 23 '20 at 17:12

1 Answers1

4

According to this, the problem is in the browser link. I had the same problem in an ASPNET MVC 5 project with Visual Studio 2019. After turning off the browser link everything is working right.

vfabre
  • 1,388
  • 12
  • 23
  • This is still an issue for me with latest version of Visual Studio. Is this a VS bug or it caused by something in our projects? Seems strange that I have to permanently disable BrowserLink for an MVC5 project. – Ciaran Gallagher Feb 06 '20 at 11:07
  • Yes, it still is as of today. And also yes, turning off browser link is still the solution. I wish I'd found this a few hours ago.... Browser link, to be honest, has been always been trash so I don't know why I ever enable it. – user2592124 Feb 11 '20 at 23:53