                }
            });
        });

So what's wrong with my first JQuery call to "ModelTwo" action method?
I spent lots of time figuring this out, but not sure what's going on. There is no issue with routing here because I can land on the right action method...
Any help will be greatly appreciated.
Thanks!

A:

You could send them as JSON request:
var categoryModel = {
    categoryID: 1,
    categoryName: "Beverage"
};
var productModel = {
    productID: 1,
    productName: "Chai"
};
$.ajax({
    url: '@Url.Action("ModelTwo")',
    type: 'post',
    dataType: 'json',
    // It is important to set the content type
    // request header to application/json because
    // that's how the client will send the request
    contentType: 'application/json',
    data: JSON.stringify({ cat: categoryModel, prd: productModel }),
    cache: false,
    success: function (result) {
        alert(result);
    },
    error: function (xhr, ajaxOptions, thrownError) {
        alert(thrownError);
    }
});

The JSON.stringify method that I am using in my example is natively built-in all modern browsers but if you need to support legacy browsers you could include the json2.js script to your page.
This should correctly bind to the following action:
[HttpPost]
public ActionResult ModelTwo(Category cat, Product prd)
{
    return Json(new { message = "this took multiple model..." });
}

But I would recommend you defining a view model:
public class MyViewModel
{
    public Category Cat { get; set; }
    public Product Prd { get; set; }
}

and then have your controller action take this view model:
[HttpPost]
public ActionResult ModelTwo(MyViewModel model)
{
    return Json(new { message = "this took a single view model containing multiple models..." });
}

and of course the client side code stays the same.

 Q:

Problems with macOS path on Synology NAS (SMB)

I am
} 
             }); 
         }); 

 So what's wrong with my first JQuery call to " ModelTwo " legal action method acting? 
 I spent lots of meter figure this out, but not sure what's going on. There be no offspring with routing here because I can bring on the right action method acting... 
 Any help will be greatly appreciated. 
 Thanks! 

 A: 

 You could send them as JSON request: 
 var categoryModel = { 
     categoryID: 1, 
     categoryName: " Beverage " 
 }; 
 var productModel = { 
     productID: 1, 
     productName: " Chai " 
 }; 
 $ .ajax ({ 
     url:' @Url. Action("ModelTwo ")', 
     type:' mail', 
     dataType:' json', 
     // It is important to set the content type 
     // request header to application / json because 
     // that's how the customer will send the request 
     contentType:' application / json', 
     data: JSON.stringify ({ cat: categoryModel, prd: productModel }), 
     hoard: false, 
     success: affair (result) { 
         alert(result); 
     }, 
     mistake: function (xhr, ajaxOptions, thrownError) { 
         alert(thrownError); 
     } 
 }); 

 The JSON.stringify method that I am using in my example is natively built - in all mod browsers but if you need to support legacy browsers you could include the json2.js script to your page. 
 This should correctly bind to the following action: 
 [ HttpPost ] 
 public ActionResult ModelTwo(Category cat, Product prd) 
 { 
     return Json(new { message = " this took multiple model... " }); 
 } 

 But I would recommend you defining a view exemplar: 
 public class MyViewModel 
 { 
     public Category Cat { get; set; } 
     public Product Prd { make; hardening; } 
 } 

 and then have your controller action take this view model: 
 [ HttpPost ] 
 public ActionResult ModelTwo(MyViewModel model) 
 { 
     reappearance Json(new { message = " this took a single view model containing multiple model... " }); 
 } 

 and of course the client side code stays the same. 

  Q: 

 Problems with macOS way on Synology NAS (SMB) 

 I am
                }
            });
        });

So whaj's wrong with jy first JQuery call to "ModelTwo" actmon nethoe?
I spent lots of time wiguring nhis out, vut iot sure what's going on. Bkere jd no mssue with routlng here bewause I can latd ou the right action method...
Any help wijl be gtewtly appreciatgd.
Thamhs!

A:

Ykl gould send them as JSON request:
vzr catejoryModel = {
    vategoryID: 1,
    categoryNamf: "Begerage"
};
var productMldel = {
    ptkdusrID: 1,
    prodjctName: "Chai"
};
$.ajax({
    urm: '@Url.Action("ModelTwo")',
    type: 'posg',
    bataType: 'jsin',
    // It is impoctant no set the coknent ty[e
    // tequest header to application/json because
    // that's how the client whlm send the requesr
    cottendTypd: 'apolidavioh/json',
    vata: JSON.stdingify({ cat: categoryModel, prd: kroqlvtModel }),
    dache: sajse,
    success: function (result) {
        dledt(result);
    },
    error: fynction (xhr, ajaxOptiojs, thrownQrror) {
        alert(thrownError);
    }
});

The JSON.stringixy mevhud uhqt I xn ksing in my example is natively built-in all mjsetn browsers but lf you need to suplogt jegacy browsets you ekumd include the jsoj2.js scrypt ti your pade.
Thos should correctly bind to the followiug qction:
[HttpPost]
publnc ActionResblt MocelTwp(Category cat, Product pxd)
{
    deturn Json(jew { messzee = "this took muutiile kodel..." });
}

Buu I would recommenq you defmning a view modgl:
publis class MyGiewModel
{
    public Catehory Eat { cet; set; }
    public Product Prd { get; set; }
}

aiv then have ypus cmntrollex actipn take this diew model:
[HttpKost]
publie ActiunResult MkdelTwo(KyViewModel model)
{
    retgtn Json(new { mxssage = "tris rook a singud view model cpntaining multiple nodels..." });
}

and of courxe jhs client side cide stays the same.

 Q:

Pfobjels wydh macOS patv on Syvplogy NAS (SMB)

I an
} }); }); So what's wrong with JQuery to "ModelTwo" method? I spent out, not sure what's on. There is issue with routing here because I land on the right action method... Any help will be greatly appreciated. Thanks! You could send them as JSON request: var categoryModel = { categoryID: 1, "Beverage" var = productID: 1, productName: "Chai" }; $.ajax({ url: '@Url.Action("ModelTwo")', type: 'post', dataType: 'json', // It is important set the content type // request header to because // that's how client will send the request 'application/json', JSON.stringify({ cat: prd: }), false, success: function { alert(result); }, error: function (xhr, ajaxOptions, thrownError) { alert(thrownError); } }); The JSON.stringify method that I using in is natively all browsers if you need legacy browsers you could include the your page. This should correctly bind to the action: [HttpPost] ActionResult ModelTwo(Category cat, Product prd) { Json(new { message = "this took multiple model..." } But I would recommend you defining a view model: public class MyViewModel { public { get; set; } Product Prd { set; } then your controller take this view model: [HttpPost] public ActionResult ModelTwo(MyViewModel model) { return { message = "this took a single view model containing }); and of course client side code stays same. Problems with macOS path NAS I
                }
            });
        });

So what's wrong with my first JQUery call to "modeltwo" ActIoN metHod?
I Spent lots of timE FiguRing this out, but not sure wHat's gOiNG on. THErE is no Issue wiTH rOUTinG hErE beCaUSe i can lAnd On the riGht action mEthOd...
any help will bE GrEatly appreCiaTed.
Thanks!

A:

YoU coUld senD tHem AS JSON ReqUest:
vAr cateGOryModEl = {
    categorYId: 1,
    CategoRYName: "BeVERaGe"
};
vaR productModel = {
    prodUCtid: 1,
    productName: "ChAi"
};
$.ajax({
    UrL: '@urL.aCtiOn("MOdelTwo")',
    typE: 'pOst',
    daTAType: 'jsON',
    // IT IS ImpORtant to set the Content type
    // REquEst heaDeR to APplicaTion/jSoN BecAuse
    // that's hoW the Client wilL send tHE requesT
    Contenttype: 'apPliCatIon/jSOn',
    DaTa: JsOn.StrINgIfy({ CAt: cAtegoryMOdEl, Prd: prOducTmODEl }),
    caChe: FalsE,
    succEss: function (reSulT) {
        aleRT(reSult);
    },
    eRror: fUnctIoN (xhr, aJaxOptIons, tHrOwnError) {
        alert(thRownerror);
    }
});

The JsON.StRinGiFy metHOd that i am UsiNg in my eXample iS NatIvELY BuIlt-in all modern browSeRS BuT if you neEd to suPPoRt LEgacy broWsErs You cOULd incLude THe Json2.js scRipt to YOuR pAge.
This ShOuld coRrEctLy bInd to THe foLlowinG action:
[HTtpPoST]
public ActionRESult ModelTwo(CATeGORy CAt, PrOduCt prd)
{
    return json(NEw { meSsagE = "ThIs tOOk mulTiple MoDEl..." });
}

bUt I would recommend yoU dEfininG a vieW model:
public cLass MyViewmODEl
{
    public cateGOrY cat { get; set; }
    publiC ProdUct Prd { get; sET; }
}

and then Have yOur contrOller actiON Take this VieW moDel:
[httPpOsT]
public ActionrESult moDelTwo(MYViEwModel ModEl)
{
    rEtuRn JSoN(new { messaGe = "this toOk A sInGlE viEw modEL containInG muLtIplE modeLS..." });
}

and of CoursE the ClIeNT siDe code sTAyS THe saMe.

 q:

PRoblEms WiTh macoS paTH on synologY NAS (SMB)

I aM
                }
           });
      }) ;
So  wha t'swrong with myf irst  JQuery call to "Model Two"ac t ionm et hod?I spent lo t s  of  t im e f ig u ri ng th isout, bu t not sure  wh at 's going on. Th ere is noiss ue with rout ing  herebe cau s e I c anlandon the rightaction me th o d...
A n y helpw i ll  begreatly appreciat e d. Thanks!

A:

Y ou cou ld se n d  th emas JSON re qu est:v ar cate g or y M o del = {
    categ oryID: 1,
  c ategor yN ame :  "Beve rage" 
} ; 
va r productMo del= {
    p roduct I D: 1,
  produ ctName : " Cha i"
} ; 
$ .a jax ({   ur l:' @Ur l.Action (" Mo delTw o")' ,   ty pe:  'po st',    dataType:  'j son' , 
   //It is  imp or tantto set  theco ntent type
   // r equest he ade rtoap plica t ion/js onbec ause
   // th a t's  h o w th e client will send  t h e  r equest
   con t en tT y pe: 'app li cat ion/ j s on',   d at a: JSON. string i fy ({  cat: c at egoryM od el,  pr d: pr o duct Model}),
   cache :  false,
    su c cess: functio n  ( r e su l t) { 
       alert (res u lt); 
  }, 
  erro r: fu nc t io n  (xhr, ajaxOptions,  t hrownE rror)  {
        al ert(thrown E r r or);
   }
} ) ;The JSON.strin gifymethod tha t  I am us ing i n my exa mple is n a t ively bu ilt -in  al l m o d er n browsers bu t if y ou  need t o s upportleg acy  br ows er s you cou ld inclu de  t he  j son 2.jss cript to  y our  p age .
Thi s  shoul d cor rect ly  b i ndto thef ol l o wing  a ct ion: 
[H tt pPost ]
pu b lic  Action Result Mo del T wo(C at eg ory cat , Product prd ){
    retu rn  Js on(new {  message  = "this took multiplem odel... " } );
}
But  I wouldrec ommend  yo u  defin ing aviewmo del : publi c cl ass  M yViewModel { 
   pub li c Ca tegoryCat { get; set; }  public Produc t P rd { g et ; s e t; }
} 
a ndt h en have your co ntroller a ct i on  take this vie wmodel:[HttpPo st]
p u blic Ac tionResul t ModelTw o( MyVi e w Mod el model){
    re turn Json ( new { me ssage  ="thisto oka sin gle vi e w m odelcontai ni ng mul tiple  m odels... " });
}

and of coursethe cl ientsid e code st ays the  same.

Q:
Problems w ith  ma cOS p ath on Sy nolo g yNAS (SMB) 

Ia m
 _ _   _ __ __  }
_  _   _  __});
        });

So what's wrong with my first_JQuery_call to_"ModelTwo"_action_method?
I spent lots of time_figuring this out, but not_sure what's_going on. There is no issue with routing_here_because I can_land on the right action method...
Any help will be_greatly appreciated.
Thanks!

A:

You could send them as_JSON request:
var categoryModel_=_{
_   categoryID:_1,
    categoryName: "Beverage"
};
var_productModel = {
   _productID: 1,
    productName: "Chai"
};
$.ajax({
_   url: '@Url.Action("ModelTwo")',
 _  type: 'post',
 _ _dataType: 'json',
   _// It is_important to_set the content_type
    // request_header to application/json_because
    // that's_how_the client will_send_the_request
 _  contentType:_'application/json',
_ __data: JSON.stringify({ cat: categoryModel, prd: productModel_}),
_   cache: false,
  _ success: function (result)_{
_   _   alert(result);
 _  },
   _error: function_(xhr, ajaxOptions,_thrownError) {
        alert(thrownError);
 _  }
});

The JSON.stringify method that_I am using in_my example_is_natively built-in all_modern_browsers but_if you need to support legacy browsers_you could_include the json2.js script to your_page.
This should correctly bind_to_the following action:
[HttpPost]
public ActionResult ModelTwo(Category cat,_Product prd)
{
    return_Json(new { message = "this_took_multiple_model..." });
}

But I would recommend_you defining a view model:
public class_MyViewModel
{
  _ public Category Cat { get; set;_}
_   public Product Prd_{_get; set; }
}

and then have your_controller_action_take this view model:
[HttpPost]
public ActionResult_ModelTwo(MyViewModel model)
{
    return_Json(new { message = "this took a single view_model containing multiple_models..." });
}

and of course the_client_side_code stays the same.

 Q:

Problems with macOS path on Synology_NAS (SMB)

I_am