Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
140 views
in Technique[技术] by (71.8m points)

c# - ASP.NET Core dynamic ports for Pub/Sub

I am creating pub sub for ASP.NET Core API and multiple ASP.NET Core MVC Clients. So I would have some API Calculation who would send changed data to API Pub/Sub Service and him to send to subscribed MVC Clients. My problem is that in mine MVC Client app in launchSettings.json there is set port

"iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:50187", "sslPort": 44366 }

Currently this is the why I am connecting to my MVC Client from ASP Pub/Sub service

HttpClient client = new HttpClient();
        string baseUrl = Configuration.GetValue<string>("AppSettings:BaseUrl");
        client.BaseAddress = new Uri(baseUrl);

        var contentType = new MediaTypeWithQualityHeaderValue("application/json");
        client.DefaultRequestHeaders.Accept.Add(contentType);

        HttpResponseMessage response = await client.GetAsync(employeesApiUrl + "/Create?model=" + "Ok");

So this is my first time programing in ASP.NET Core and I wonder is my approach good and how can I make dynamic port so every new client have its own unique port?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...