public IActionResult Edit(Guid id, [Bind("Id,Name,FathersName,Age")] Models.Student student)
        {
            System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
            client.BaseAddress = new Uri(_configuration.GetValue <string>("AppConfig:Url"));
            System.Net.Http.ObjectContent content = new System.Net.Http.ObjectContent(typeof(Models.Student), student, new System.Net.Http.Formatting.JsonMediaTypeFormatter());
            var result = client.PutAsync("/api/StudentService/", content).Result;

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            if (actionExecutedContext.Response != null)
            {
                System.Net.Http.ObjectContent content = actionExecutedContext.Response.Content as System.Net.Http.ObjectContent;

                if (content != null && content.ObjectType != null)
                {
                    actionExecutedContext.Response.Headers.Add("X-Object-Type", content.ObjectType.Name);
                }
            }

            base.OnActionExecuted(actionExecutedContext);
        }