Skip to content

Instantly share code, notes, and snippets.

@squadwuschel
Created June 28, 2016 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squadwuschel/010b5ae41f9fe468a139c2323fa1c7ea to your computer and use it in GitHub Desktop.
Save squadwuschel/010b5ae41f9fe468a139c2323fa1c7ea to your computer and use it in GitHub Desktop.
.NET Controller für AngularJs Proxy
public class ProxyController : Controller
{
[CreateAngularTsProxy(ReturnType = typeof(Auto))]
public JsonResult AddTsEntryAndName(Person person, string name)
{
return Json(new Auto() { Marke = name}, JsonRequestBehavior.AllowGet);
}
[CreateAngularTsProxy(ReturnType = typeof(Person))]
public JsonResult LoadTsCallById(int id)
{
return Json(new Person() { Id = id}, JsonRequestBehavior.AllowGet);
}
[CreateAngularTsProxy(ReturnType = typeof(Person))]
public JsonResult LoadTsCallByParams(string name, string vorname, int alter)
{
return Json(new Person() { Name = name, Id = alter}, JsonRequestBehavior.AllowGet);
}
[CreateAngularTsProxy(ReturnType = typeof(void))]
public JsonResult VoidTsReturnType(string name)
{
return Json(string.Empty, JsonRequestBehavior.AllowGet);
}
[CreateAngularTsProxy(ReturnType = typeof(string))]
public JsonResult StringTsReturnType(string name)
{
return Json(name, JsonRequestBehavior.AllowGet);
}
[CreateAngularTsProxy(ReturnType = typeof(int))]
public JsonResult IntegerTsReturnType(int age)
{
return Json(age, JsonRequestBehavior.AllowGet);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment