asp.net-core-mvc

C# ASP.NET Core - SocketException: No such host is known

北城以北 提交于 2021-02-20 09:11:59
问题 I am having issues which seem to be related calling a specific API asynchronously using HttpClient - the strange thing is that it doesn't happen all the time and can be solved by refreshing the page (sometimes once, sometimes multiple times). I thought this could be a local issue but hosting on Azure produces the same results. Raw exception details: System.Net.Sockets.SocketException (11001): No such host is known at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port,

C# ASP.NET Core - SocketException: No such host is known

夙愿已清 提交于 2021-02-20 09:11:37
问题 I am having issues which seem to be related calling a specific API asynchronously using HttpClient - the strange thing is that it doesn't happen all the time and can be solved by refreshing the page (sometimes once, sometimes multiple times). I thought this could be a local issue but hosting on Azure produces the same results. Raw exception details: System.Net.Sockets.SocketException (11001): No such host is known at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port,

C# ASP.NET Core - SocketException: No such host is known

≡放荡痞女 提交于 2021-02-20 09:09:55
问题 I am having issues which seem to be related calling a specific API asynchronously using HttpClient - the strange thing is that it doesn't happen all the time and can be solved by refreshing the page (sometimes once, sometimes multiple times). I thought this could be a local issue but hosting on Azure produces the same results. Raw exception details: System.Net.Sockets.SocketException (11001): No such host is known at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port,

Redirect outside of the Controllers context in ASP.NET Core

做~自己de王妃 提交于 2021-02-19 16:43:30
问题 I do not know if this is actually possible, but I think it' s worth a try to find out. There are maybe other and better patterns (if you know one let me know, I will look them up) to do this, but I'm just curious to know if this is possible. When you have to call an API you could do it directly from within the controller using the HttpClient like this: [Authorize] public async Task<IActionResult> Private() { //Example: get some access token to use in api call var accessToken = await

Can a Controller support a route with variable string parameters?

我们两清 提交于 2021-02-19 08:24:47
问题 I want to support routes such as /route/param1 , /route/param1/param2 , /route/param1/param2/param3 and so on. For now I have define in my Controller one route per combination of parameters: [Route("{path1}")] public async Task<IActionResult> Route1(string path1) { return await ParsePath(new[] { path1 }); } [Route("{path1}/{path2}")] public async Task<IActionResult> Route2(string path1, string path2) { return await ParsePath(new[] { path1, path2 }); } This has 2 major drawback: For now I have

Register collection of services in MVC Core DI

流过昼夜 提交于 2021-02-19 04:22:18
问题 I`ve got simple class with strategies. public class LinkQualifier : ILinkQualifier { private readonly IEnumerable<IQualifier> _qualifiers; public LinkQualifier(IEnumerable<IQualifier> qualifiers) { _qualifiers = qualifiers; } public IQualifier Qualify(Uri uri) { return _qualifiers.FirstOrDefault(q => q.CanQualify(uri)); } } How i can register it in MVC core DI container? I invented something like this: services.AddTransient<ILinkQualifier, LinkQualifier>((ctx => { var qualifiers = new List

asp .net core app doesn't set response cookie in IE and EDGE but works well in firefox and chrome

蹲街弑〆低调 提交于 2021-02-19 01:37:10
问题 I have a login controller with a post action which redirects to home page after successful login. I am using following code for redirection, which works well in Chrome and Firefox. but doesn't redirect in IE and EDGE, and response cookie not set private ActionResult RedirectToLocal(string returnUrl) { if (Url.IsLocalUrl(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToRoute("default", new { controller = "", action = "" }); } } My Login action public IActionResult Login

UserManager.FindAsync(username, password) not available in ASP.NET 5 / Identity 3

a 夏天 提交于 2021-02-19 01:16:53
问题 I'm trying to upgrade a project to ASP.NET 5 / MVC 6. The UserManager that came with AspNet.Identity used to have a FindAsync method where I could pass in a username and password. It doesn't seem to be there anymore. I don't think I need the SigninManager or Authentication as I'm using JWT Bearer Authentication. I just need to check the username and password are valid before I grant an access token, 回答1: Simply use UserManager.FindByNameAsync() to find the user object then check its password:

UserManager.FindAsync(username, password) not available in ASP.NET 5 / Identity 3

爷,独闯天下 提交于 2021-02-19 01:16:27
问题 I'm trying to upgrade a project to ASP.NET 5 / MVC 6. The UserManager that came with AspNet.Identity used to have a FindAsync method where I could pass in a username and password. It doesn't seem to be there anymore. I don't think I need the SigninManager or Authentication as I'm using JWT Bearer Authentication. I just need to check the username and password are valid before I grant an access token, 回答1: Simply use UserManager.FindByNameAsync() to find the user object then check its password:

UserManager.FindAsync(username, password) not available in ASP.NET 5 / Identity 3

匆匆过客 提交于 2021-02-19 01:16:23
问题 I'm trying to upgrade a project to ASP.NET 5 / MVC 6. The UserManager that came with AspNet.Identity used to have a FindAsync method where I could pass in a username and password. It doesn't seem to be there anymore. I don't think I need the SigninManager or Authentication as I'm using JWT Bearer Authentication. I just need to check the username and password are valid before I grant an access token, 回答1: Simply use UserManager.FindByNameAsync() to find the user object then check its password: