asp.net-core-2.0

How to set timeout of soapclient in .net core project

為{幸葍}努か 提交于 2020-01-03 03:09:35
问题 I have to use a SOAP service in a .Net Core 2.0 project. I added service reference as described in following link: ( Missing link, 404 ) Service is working fine for some methods. However, some methods are taking long time (due to the operations service is doing) and in this case the program is throwing exception:"System.Net.Http.WinHttpException: The operation timed out" I tried to set the timeout value but it has no effect. MyService.MyServiceSoapClient Pr = new MyService.MyServiceSoapClient

How to test Ok() result using MStest in ASP.NET Core project

我的梦境 提交于 2020-01-02 04:34:07
问题 I'm using MStest for testing my controllers. I want to test this action: [HttpGet(Name = "GetGroups")] public async Task<IActionResult> Get() { var groups = await _unitOfWork.Repository<Groupe>().GetAllAsync(); var groupsDto = Mapper.Map<IEnumerable<GroupDto>>(groups); if (groupsDto.Count() == 0) { return NotFound(); } return Ok(groupsDto); } One of the test for this action looks like that: [TestMethod] public async Task Group_Get_Should_Return

The type ApplicationUser cannot be used as type parameter 'TUser' in the generic type or method 'IdentityDbContext<TUser>'

ε祈祈猫儿з 提交于 2020-01-02 04:09:19
问题 Trying to implement Identity in ASP.NET Core 2.0. Having many problems getting my head around this. Startup.cs public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer

Accessing Session object inside an Asp Core 2 View

北战南征 提交于 2020-01-02 03:45:07
问题 I want to show Session in view. Is that possible? I try with this in my view <div class="content-header col-xs-12"> <h1>Welcome, @HttpContext.Session.GetString("userLoggedName")</h1> </div> But i get an error Severity Code Description Project File Line Suppression State Error CS0120 An object reference is required for the non-static field, method, or property 'HttpContext.Session' Any help, i will appreciate it. Thanks 回答1: You can inject IHttpContextAccessor implementation to your view and

Function host is not running

孤街醉人 提交于 2020-01-02 01:16:07
问题 I have a Function App in azure and when I hit the URL of the function app it says "Function host is not running." I am not sure where I have to check and what needs to be changed. I tried restart but still no luck. 回答1: This usually means that there is some bad configuration in your function app which is causing the host to fail to start up. Things like having an invalid host.json or an invalid proxies.json file are a possible cause. To diagnose, it's best to look at the function host logs.

How to execute .Net Core 2.0 Console App using Windows Task Scheduler?

試著忘記壹切 提交于 2020-01-02 01:13:10
问题 I have one Console App which is created using asp.net Core 2.0 in VS2017 . Now I want to run this application on particular time period repeatedly (like service). So I have tried this using Windows Task Scheduler but when we create task using Task Scheduler it ask for .exe file of Console app. (please check below pic) But as you can see that When we create Console App using .Net Core 2.0 there will no .exe file under bin/debug folder. Anyone have idea that how to schedule a .net Core 2.0

Can't use registered singetons in ConfigureServices without them being instantiated twice

China☆狼群 提交于 2020-01-01 14:34:13
问题 I have a .Net Core project that registers a number of Singletons as follows: public void ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); services.AddLogging(); services.AddSingleton<IConfiguration>(Configuration); services.AddSingleton<IDbFactory, DefaultDbFactory>(); services.AddSingleton<IUserRepository, UserRepository>(); services.AddSingleton<IEmailService, EmailService>(); services.AddSingleton<IHostedService, BackgroundService>(); services.AddSingleton

Recycle of App Pool kills Kestrel but does not restart

假装没事ソ 提交于 2020-01-01 13:15:12
问题 Background When hosting a (non-Core) ASP.net site on IIS 8+ it is possible to utilize the IIS Application Initialization Module to pro-actively initialize ('warm-up') a web application when IIS starts up (or, I believe, when an app pool is recycled). As far as I know, this is not possible when hosting a .net Core app on IIS. I have also noticed that when hosting a .net Core (1.1) app on IIS, the dotnet.exe process (Kestrel) is killed as part of an application pool recycle event. This process

Publish ASP.Net Core 2.1preview2 website to local IIS MSB3030 *.PrecompiledViews.dll

Deadly 提交于 2020-01-01 12:12:11
问题 Update 1 With @Priyesh Kumar feedback I have used the following command from the websites root folder (the one with *.csproj for the website). This worked. I then copied the "win10-x64" content files into c:\www\sigex.com. dotnet publish -c Release -r win10-x64 --self-contained I am running into a few different issues now but will fix them and then post back the solution. Original Post Hi I am trying to publish my website locally into IIS (a site I have made in IIS manager). I am using the

Empty authorization header on requests for Swashbuckle.AspNetCore

一笑奈何 提交于 2019-12-31 06:29:33
问题 Currently having an issue with authorization headers in swashbuckle for .net core The first line of code on every endpoint is: string auth = Request.Headers["Authorization"]; When using postman, everything works smoothly, but when making a request from localhost/swagger, the header is empty when a breakpoint is inserted, the header is a null value. the body of the request is in tact and everything works properly when the authorization is removed from the endpoint In my services.AddSwaggerGen