Гость
Map
Форумы / Microsoft SQL Server [закрыт для гостей] / Не могу подключиться к БД / 4 сообщений из 4, страница 1 из 1
31.07.2022, 16:21
    #103893
Alexander
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не могу подключиться к БД
Приложение .net blazor server . Приложение не может подключиться к базе данных . При этом браузер пишет , что была попытка подключения к базе данных с другим именем(это старая, колторую я удалил.) Эксперементальным способом выяснил, что обращение к строке подключения вообще не происходит. Я меняю допустим название подключения, все равно одно и то же.
Причем когда я публикую приложение на хостинге, там могу настроить, и все работает. Ошибка только на локалхосте
на хостинге срабатывает файл appsettings.production.json.
Вот стартап.
Код: C#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using jeansBlazorAsh.Data;
using jeansBlazorAsh.Models;
using Microsoft.EntityFrameworkCore;
using jeansBlazorAsh.Areas.Identity;
using Microsoft.AspNetCore.Identity;
using Blazored.LocalStorage;
using Blazored.Toast;
using Microsoft.AspNetCore.Identity.UI.Services;
using jeansBlazorAsh.Repo;

namespace jeansBlazorAsh
{
    public class Startup
    {
        public Startup(IConfiguration configuration, IWebHostEnvironment env)
        {
            Configuration = configuration;
            _env = env;
        }

        public IConfiguration Configuration { get; }
        public IWebHostEnvironment _env { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {

            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddBlazoredLocalStorage();
            services.AddBlazoredToast();
            services.AddScoped<GoodStockService>();
            services.AddScoped<CartService>();
            services.AddScoped<NotIdentCartService>();
            services.AddScoped<NotIdentUserService>();
            services.AddScoped<UserService>();
            services.AddScoped<SaveNotifyOrderService>();
            services.AddScoped<PaySuccessService>();
            services.AddScoped<AppState>();
            services.AddScoped<ResponseOptions>();
            services.AddTransient<IEmailSender, EmailService>();
            services.AddAuthentication()
                .AddGoogle(options => {
                    IConfigurationSection googleAuthSection = Configuration.GetSection("Authentication:Google");

                    options.ClientId = googleAuthSection["client_id"];
                    options.ClientSecret = googleAuthSection["client_secret"];
                });

            //services.Configure<AuthMessageSenderOptions>(Configuration);

            //для rest
            services.AddHttpClient();

            services.AddDbContext<Point4Context>(options =>
                options.UseSqlServer(
                    Configuration.GetConnectionString("DefaultConnection"),
                 providerOptions => providerOptions.EnableRetryOnFailure()));

            services.AddScoped<TokenProvider>();
            services.Configure<IdentityOptions>(options =>
            {
                // Default Password settings.
                options.Password.RequireDigit = false;
                options.Password.RequireLowercase = false;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase = false;
                options.Password.RequiredLength = 6;
                options.Password.RequiredUniqueChars = 0;
            });
            services.AddServerSideBlazor().AddCircuitOptions(o =>
            {
                if (_env.IsDevelopment()) //only add details when debugging
                {
                    o.DetailedErrors = true;
                }
            });
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");
            });
        }
    }
}
вот appsettings.json (пароль я убрал)
Код: JSON
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
{
  "AllowedHosts": "*",
  "Authentication": {
    "Google": {
      "client_id": "**********************************************",
      "project_id": "stellar-shard-151317",
      "auth_uri": "https://accounts.google.com/o/oauth2/auth",
      "token_uri": "https://oauth2.googleapis.com/token",
      "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
      "client_secret": "********************************************"
    }
  },
  "ConnectionStrings": {
    "DefaultConnection": "Data Source=wpl41.hosting.reg.ru;Initial Catalog=u1238630_2Emp;Persist Security Info=True;User ID=u1238630_AV;Password=*******",
    "jeansBlazorAshContextConnection": "Data Source=wpl41.hosting.reg.ru;Initial Catalog=u1238630_2Emp;Persist Security Info=True;User ID=u1238630_AV;Password=*******"
  },
  "DetailedErrors": true,

  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information",
      "Microsoft.AspNetCore.SignalR": "Debug",
      "Microsoft.AspNetCore.Http.Connections": "Debug"
    }
  },

  "Pay": {
    "Sber": {
      "userName": "P504200132446-api",
      "password": "********"
    }
  }
}
ничего не понимаю.
...
Рейтинг: 0 / 0
31.07.2022, 16:24
    #103912
IT-Христ
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не могу подключиться к БД
Брандмауэр посмотри.
...
Рейтинг: 0 / 0
02.08.2022, 07:18
    #105275
AK
AK
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не могу подключиться к БД
Alexander [игнорируется] 

проверь telnet
проверь логи SQL Server
...
Рейтинг: 0 / 0
02.08.2022, 10:55
    #105417
Дед-Папыхтет
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не могу подключиться к БД
Alexander [игнорируется] 

SQL Server Configuration Manager - проверь настройки
sqltcp.JPG
...
Рейтинг: 0 / 0
Форумы / Microsoft SQL Server [закрыт для гостей] / Не могу подключиться к БД / 4 сообщений из 4, страница 1 из 1
Целевая тема:
Создать новую тему:
Автор:
Найденые пользователи ...
Разблокировать пользователей ...
Читали тему (1): Анонимы (1)
Читали форум (1): Анонимы (1)
Пользователи онлайн (98): anonymous, Анонимы (75), Сталкер, Брюквенные годы, Vaska Balboa, Дед-Папыхтет, Tayfur, Гарыныч, Redd, Yandex Bot, IT-Клоп, Green, С чистого листа, ElenaG 1 мин., Буся 2 мин., паразит 2 мин., Antonariy 3 мин., Разум вселенной 3 мин., Bing Bot 3 мин., Кусь 3 мин., wIWIw 5 мин., cat2 5 мин., Неуловимый Джо 7 мин., Ибрагимов Мага 82 8 мин.
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]