🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# Web Api MVC RMOS / C# Web Api MVC RMOS Genel Bilgiler

1-) C# Web Api MVC RMOS - C# Web Api MVC RMOS Genel Bilgiler

Controllers-> add new controller

 

apide resim kaydetmek :

HttpContext.Current.Server.MapPath("~/images/resim.jpg");

 

 

 

 

App_Start -> WebApiConfig.cs -> aşağıdakini ekle

 

 config.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings();

 

 

> metot aşağıdakigibi olacak

 

 //[System.Web.Mvc.Route("api/Barkod/GetCari/{plan_kod}")]

        public HttpResponseMessage GetCari(string plan_kod)

        {

            DataTable dt = RHVeritabani.MyGetDataTable("select Plan_Id,plan_kod,plan_ad from muh_plan where Plan_Grup=2 and plan_kod='320.01.U005'");

            return Request.CreateResponse(HttpStatusCode.OK, dt);

        }

 

> WebApiConfig.cs (yandaki gibi ayarla routeTemplate: "api/{controller}/{action}/{id}",)

 

 public static void Register(HttpConfiguration config)

        {

            // Web API configuration and services

            // Configure Web API to use only bearer token authentication.

            config.SuppressDefaultHostAuthentication();

            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

 

            config.Formatters.JsonFormatter.SupportedMediaTypes

    .Add(new MediaTypeHeaderValue("text/html"));

 

            // Web API routes

            config.MapHttpAttributeRoutes();

 

            config.Routes.MapHttpRoute(

                name: "DefaultApi",

                routeTemplate: "api/{controller}/{action}/{id}",

                defaults: new { id = RouteParameter.Optional }

            );

        }

 

 

 

 2021 Kasım 01 Pazartesi
 448