Yervand Mazlumyan
Yervand Mazlumyan

Reputation: 35

The request was aborted: The connection was closed unexpectedly. on Helper methods

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.

Upvotes: 2

Views: 1989

Answers (1)

vfabre
vfabre

Reputation: 1408

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.

Upvotes: 4

Related Questions