GVKun编程网logo

控制台出现错误:无法加载资源:net :: ERR_CONNECTION_RESET(无法加载控制器:5e1e5cb1d3841476ceb279da1db2e905)

7

在本文中,您将会了解到关于控制台出现错误:无法加载资源:net::ERR_CONNECTION_RESET的新资讯,同时我们还将为您解释无法加载控制器:5e1e5cb1d3841476ceb279da

在本文中,您将会了解到关于控制台出现错误:无法加载资源:net :: ERR_CONNECTION_RESET的新资讯,同时我们还将为您解释无法加载控制器:5e1e5cb1d3841476ceb279da1db2e905的相关在本文中,我们将带你探索控制台出现错误:无法加载资源:net :: ERR_CONNECTION_RESET的奥秘,分析无法加载控制器:5e1e5cb1d3841476ceb279da1db2e905的特点,并给出一些关于.net 上传文件 Failed to load resource: net::ERR_CONNECTION_RESET Bug 解决、Ajax POST调用ASP.NET MVC控制器给出net :: ERR_CONNECTION_RESET、ajax上传图片chrome报错net::ERR_CONNECTION_RESET/net::ERR_CONNECTION_ABORTED、ajax错误处理 net::ERR_CONNECTION_REFUSED的实用技巧。

本文目录一览:

控制台出现错误:无法加载资源:net :: ERR_CONNECTION_RESET(无法加载控制器:5e1e5cb1d3841476ceb279da1db2e905)

控制台出现错误:无法加载资源:net :: ERR_CONNECTION_RESET(无法加载控制器:5e1e5cb1d3841476ceb279da1db2e905)

我已刷新我的应用程序页面,并在控制台中收到此错误 Failed to load resource: net::ERR_CONNECTION_RESET

我试图重新安装XAMPP版本,但这对我不起作用。

答案1

小编典典

我认为您正在使用Chrome。问题是证书不匹配或证书过期。请正确检查证书。

.net 上传文件 Failed to load resource: net::ERR_CONNECTION_RESET Bug 解决

.net 上传文件 Failed to load resource: net::ERR_CONNECTION_RESET Bug 解决

环境:

.net 4.0

ashx一般处理程序

使用 html5 FormData ajax上传文件

 

功能如下:如果用户有登录,则对文件进行处理;如果用户没登录,则直接返回json,提示用户未登录

 

遇到问题:

用户登录:正常

用户没登录:调试的时候,没任何异常,浏览器显示Failed to load resource: net::ERR_CONNECTION_RESET错误。

 

解决方法:原因找了好久,考虑到可能是文件流还没跑完,直接返回json才出错的,再代码处理处理文件流,如下所示:

else
            {
                HttpFileCollection files = context.Request.Files;
                if (files.Count > 0)
                {
                    using (var stream = files[0].InputStream)
                    {
                    }
                }
                ToJSON(new { code = 0 });
            }

 

结果问题竟然解决了,虽然具体原因不是很清楚,暂时记录下bug,以后有空研究一下

Ajax POST调用ASP.NET MVC控制器给出net :: ERR_CONNECTION_RESET

Ajax POST调用ASP.NET MVC控制器给出net :: ERR_CONNECTION_RESET

关于这个问题,我的斗智斗勇.我创建了一个ASP.NET MVC 5网站,我正在本地开发和运行.我在网站上启用了SSL.我为该网站创建了一个自签名证书.当我对MVC控制器进行ajax POST调用时:
$.ajax({
    url: "/Shop/AddToCart/" + id,contentType: "application/json; charset=utf-8",type: "POST",accepts: {
        json: "application/json,text/javascript"
    },statusCode: {
        200: function(data) {
            $("#successAlert").show();
            $(function () {
                var returnObject = data;
                layoutVM.addProduct(returnObject);
            });
            },400: function() {
            $("#errorAlert").show();
            }
    }
});

我在Chrome的JavaScript控制台中收到以下错误:“net :: ERR_CONNECTION_RESET”.它也不适用于任何其他浏览器.

我知道这个错误与SSL有关.正如我所说,我为这个网站创建了一个有效的证书.除非我遗漏了什么,否则我的工具(Chrome开发工具,Glimpse,fiddler)并没有告诉我任何有用的东西.

有任何想法吗?

更新(2015年3月13日):

因此,经过进一步调查,我发现MVC控制器的动作确实被调用了.在该方法中,我返回一个HttpStatusCodeResult的实例:

[HttpPost]
public ActionResult AddToCart(int id)
{
    int numChanges = 0;
    var cart = ShoppingCart.GetCart(httpContextBase);
    Data.Product product = null;
    _productRepository = new ProductRepository();

    product = _productRepository.GetProducts()
          .Where(x => x.ProductID == Convert.ToInt32(id)).FirstOrDefault();

    if (product != null)
    {
        numChanges = cart.AddToCart(product);
    }

    if (numChanges > 0)
    {
        JToken json = JObject.Parse("{ 'id' : " + id + ",'name' : '" +  
                      product.Name + "','price' : '" + product.Price + "','count' : '" + numChanges + "' }");
        return new HttpStatusCodeResult(200,json.ToString());
    }
    else
    {
        return new HttpStatusCodeResult(400,"Product Couldn't be added to the cart");
    }

}

在方法返回HTTP 200代码后,我在Chrome中获得“net :: ERR_CONNECTION_RESET”(在其他浏览器中出错).重要的是要注意,jQuery .ajax调用中的200代码处理程序永远不会被调用.返回后立即重置连接.

根据一些博客,我应该增加maxRequestLength,我有:

<system.web>
    <httpRuntime targetFramework="4.5" 
                 maxRequestLength="10485760" executionTimeout="36000" />
</system.web>

但这没效果.

更新(2015年3月13日):

所以我更改了$.ajax调用以响应成功和错误,而不是特定的状态代码,如下所示:

$.ajax({
    url: "/Shop/AddToCart/" + id,success: function (data,textStatus,jqXHR) {
        // jqXHR.status contains the Response.Status set on the server
        alert(data);
    },error: function (jqXHR,errorThrown) {
        // jqXHR.status contains the Response.Status set on the server
        alert(jqXHR.statusCode + ": " + jqXHR.status);
    }
});

现在,即使我从控制器代码返回200,错误块也被击中.那就是进步.但是,textStatus只是“错误”而jqXHR.status只是0.

有任何想法吗?

解决方法

我已经解决了这个问题.我不明白为什么会这样,但似乎返回HttpStatusCodeResult实例的更强大的解决方案是导致连接重置的原因.当我设置响应状态代码并返回一个JToken对象时:
[HttpPost]
public JToken AddToCart(int id)
{
    int numChanges = 0;
    var cart = ShoppingCart.GetCart(httpContextBase);
    Data.Product product = null;
    _productRepository = new ProductRepository();

    product = _productRepository.GetProducts()
       .Where(x => x.ProductID == Convert.ToInt32(id)).FirstOrDefault();

    if (product != null)
    {
        numChanges = cart.AddToCart(product);
    }

    if (numChanges > 0)
    {
        JToken json = JObject.Parse("{ 'id' : " + id + ",'name' : '" + 
                    product.Name + "','count' : '" + numChanges + "' }");

        Response.StatusCode = 200;
        return json;
    }
    else
    {
        Response.StatusCode = 400;
        Response.StatusDescription = "Product Couldn't be added to the cart";
        return JObject.Parse("{}");
    }
}

一切正常.

我很乐意理解为什么.但是,就目前而言,这是我的解决方案.

ajax上传图片chrome报错net::ERR_CONNECTION_RESET/net::ERR_CONNECTION_ABORTED

ajax上传图片chrome报错net::ERR_CONNECTION_RESET/net::ERR_CONNECTION_ABORTED

网上搜了一下,base64图片太大,tomcat对post请求大小有默认限制,要在tomcat配置文件server.xml 加一个:maxPostSize="0",0表示无限制

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"  maxPostSize="0"/>  

我的项目是部署到\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps里面的

刚开始是修改d://里的tomcat的server.xml,无效

折腾一圈,修改eclipse里的server的配置,无效

最后,项目部署的目录里还有一个tomcat配置,这回总算行了吧,但依然无效

 

 

最后,maxPostSize="0"改成了maxPostSize="10485760",设的10M,成了!

刚刚查了下,有人说tomcat7 以上就不能设置0了,要做没有限制,可以设置为负数,未验证负数

折腾大半天,tomcat卸了装,装了卸,最后也算是成了

ajax错误处理 net::ERR_CONNECTION_REFUSED

ajax错误处理 net::ERR_CONNECTION_REFUSED

请求服务器停掉的时候,浏览器会提示net::ERR_CONNECTION_REFUSED

jquery事件三种回调事件:success成功 error错误 complete只要请求完成,无论返回成功还是失败

试图捕获这类错误,经测试,它会出现在error逻辑中,error回调函数有三个参数(xhr对象,error信息,异常对象)

对于这种情况,xhr的两个状态值都是0,第二个参数会返回"error"字符串

(PS. 看到别人的博客有说出现在success逻辑中,但我测试并非如此。。。)


BTW,在项目中设置ajax全局配置,只有在单例没有这个配置选项的时候才生效,比如你在业务里某个ajax请求中设了error捕获回调,那么全局的捕获就不对对它生效了,所以最好单例中 set and only set success handler

今天关于控制台出现错误:无法加载资源:net :: ERR_CONNECTION_RESET无法加载控制器:5e1e5cb1d3841476ceb279da1db2e905的讲解已经结束,谢谢您的阅读,如果想了解更多关于.net 上传文件 Failed to load resource: net::ERR_CONNECTION_RESET Bug 解决、Ajax POST调用ASP.NET MVC控制器给出net :: ERR_CONNECTION_RESET、ajax上传图片chrome报错net::ERR_CONNECTION_RESET/net::ERR_CONNECTION_ABORTED、ajax错误处理 net::ERR_CONNECTION_REFUSED的相关知识,请在本站搜索。

本文标签: