小编ssh*_*ley的帖子

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();
            }
    }
});
Run Code Online (Sandbox Code Playgroud)

我在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(); …
Run Code Online (Sandbox Code Playgroud)

ajax asp.net-mvc ssl-certificate

6
推荐指数
2
解决办法
7339
查看次数

序列化.NET对象时缺少字段

我在使用C#序列化对象时遇到问题.当应用程序进行序列化对象时,某些字段会被序列化,但其他字段则不会.在以下代码中:

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class ACORDInsuranceSvcRqHomePolicyQuoteInqRq
{

    private string rqUIDField;

    private System.DateTime transactionRequestDtField;

    private System.DateTime transactionEffectiveDtField;

    private string curCdField;

    /// <remarks/>
    public string RqUID
    {
        get
        {
            return this.rqUIDField;
        }
        set
        {
            this.rqUIDField = value;
        }
    }

    /// <remarks/>
    public string CurCd
    {
        get
        {
            return this.curCdField;
        }
        set
        {
            this.curCdField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlIgnore()]
    public System.DateTime TransactionRequestDt
    {
        get
        {
            return this.transactionRequestDtField;
        }
        set
        {
            this.transactionRequestDtField = …
Run Code Online (Sandbox Code Playgroud)

.net c# serialization xml-serialization

3
推荐指数
1
解决办法
7168
查看次数