1

Topic: ASP.NET MVC 3 registration of a route?

Hello! Only I start to study ASP.NET MVC 3. It is necessary to implement a call ajax. var urlStr = "~/Account/Register/MyMethod"; $.ajax ({url: urlStr, dataType: "json", type: "GET", contentType: ' application/x-www-form-urlencoded; charset=utf-8 ',//replace/json to the urlenoded data: {name: ' Rintu ', email: ' Rintu@gmial.com '},//data is not json async: true, processData: true,//important to use it as true cache: false, success: function () {alert (' OK ');}, error: function (xhr) {alert (' error ' + urlStr);}}); At me always an error (error) though in file AccountController created . A method. [HttpGet] public JsonResult MyMethod () {Console. WriteLine ("Hi, friend"); return Json ("Response from Find", JsonRequestBehavior. AllowGet);} As far as I understand, it is necessary correctly  a route in file Global.asax as RegisterRoutes That there it is necessary to write for  a call of my method MyMethod?

2

Re: ASP.NET MVC 3 registration of a route?

Hello, x1, you wrote: x1> var urlStr = "~/Account/Register/MyMethod"; You did not confuse the server and client code? On the client of any tildes, it is simple/Account/Register/MyMethod. x1> data: {name: ' Rintu ', email: ' Rintu@gmial.com '},//data is not json x1> At me always an error (error) What it is is specific? What code comes from the server? What in an answer body? x1> [cs] x1> [HttpGet] x1> public JsonResult MyMethod () what for to you JsonResult if any json you do not return? And, it, parameters where? public string MyMethod (string name, string email) x1> As far as I understand, it is necessary correctly  a route in file Global.asax as RegisterRoutes If at you the web project is created not in absolutely ancient studio simply enough to hang up attribute on a method: [Route ("Account/Register/MyMethod")]... <<RSDN@Home 1.0.0 alpha 5 rev. 0 on Windows 8 6.2.9200.0>>

3

Re: ASP.NET MVC 3 registration of a route?

Hello, x1, you wrote: x1> x1> var urlStr =/MyMethod "; x1> x1> At me always an error (error) though in file AccountController created . A method. Correct the link. Or routing register in Global.asax.cs, samples a heap. Z.Y. to take last mvc. The third too anything, but without asynchronous actions and convenient control  handlings  it will be sad.