Example #1
0
        public async Task <DadosTeste> PostDadoTesteAsync(DadosTeste dadoteste)
        {
            try
            {
                var    uri     = new Uri(string.Format(Url + "/Login"));
                string data    = JsonConvert.SerializeObject(dadoteste);
                var    content = new StringContent(data, Encoding.UTF8, "application/json");
                HttpResponseMessage response = null;
                response = await client.PostAsync(uri, content);

                if (!response.IsSuccessStatusCode)
                {
                    string errorMessage = await response.Content.ReadAsStringAsync();

                    throw new Exception(errorMessage);
                }
                string responseBody = await response.Content.ReadAsStringAsync();

                DadosTeste sessionJson = JsonConvert.DeserializeObject <DadosTeste>(responseBody);
                return(sessionJson);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        // public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DadosTeste dados)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // app.UseHttpsRedirection();

            app.UseRouting();

            //app.UseAuthorization();

            app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());


            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }