An error occurred attempting to determine the process id of dotnet.exe which is hosting your application. One or more error occured

An error occurred attempting to determine the process id of dotnet.exe which is hosting your application. One or more errors occurred. That problem can occur when three things are true: your app is trying to run with SSL, your app does not have an SSL Certificate setup, and you are debugging your app (which is … Read more

Display varbinary Image in Gridview

The following will show how to retrieve an image from SQL Server and display it in a GridView on an ASP.NET web page. Create a table in the database: CREATE TABLE Surplus([Surplus Id] int not null, Department nchar(50), Category nchar(25), Item nchar(75), Visible bit, TransferableImage varbinary(max), CONSTRAINT PK_Surplus_SurplusId PRIMARY KEY([Surplus Id])); Note: If a table … Read more

Net Core: Execute All Dependency Injection in Xunit Test for AppService, Repository, etc

You are mixing unit test with integration test. TestServer is for integration test and if you want to reuse Startup class to avoid register dependencies again, you should use HttpClient and make HTTP call to controller and action that use IDepartmentAppService. If you want do unit test, you need to setup DI and register all … Read more

Access to XMLHttpRequest has been blocked origin ASP.NET CORE 2.2.0 / Angular 8 / signalr1.0.0 [(CORS Policy-Access-Control-Allow-Origin) failed]

You should add your CORS like this: services.AddCors(options => { options.AddPolicy(“CorsPolicy”, builder => builder.WithOrigins(“http://localhost:4200”) .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials() .SetIsOriginAllowed((host) => true)); }); Note: The order is important!

Net Core: Using OData in Onion Architecture, Convert Query Parameters Into Linq

It’s been ages since I wrote this function, but the links might help. GetAll() just returns an IEnumerable. [Route(“”), HttpGet] public IHttpActionResult Get(ODataQueryOptions<Language> queryOptions) { Log.Info($”{nameof(Get)} (ODataQueryOptions)”); //OData directly with normal WebAPI //https://blogs.msdn.microsoft.com/webdev/2013/02/25/translating-odata-queries-to-hql/ //https://stackoverflow.com/questions/10781309/asp-net-mvc-4-webapi-manually-handle-odata-queries //https://blogs.msdn.microsoft.com/odatateam/2014/07/04/tutorial-sample-using-odatauriparser-for-odata-v4/ //OData without entity framework, but full-on odata controller //http://www.odata.org/blog/how-to-use-web-api-odata-to-build-an-odata-v4-service-without-entity-framework/ //OData tips and tricks //https://blogs.msdn.microsoft.com/davidhardin/2014/12/17/web-api-odata-v4-lessons-learned/ return Ok(queryOptions.ApplyTo(_repository.GetAll().AsQueryable())); }

Sharing Cookies Between Two ASP.NET Core Applications

This is documented at Sharing cookies among apps with ASP.NET and ASP.NET Core. There is also a Cookie Sharing App Sample available. In order to share cookies, you create a DataProtectionProvider in each app and using a common/shared set of keys between the apps. .AddCookie(options => { options.Cookie.Name = “.SharedCookie”; options.Cookie.Domain = “example.com”; options.DataProtectionProvider = … Read more

How to resolve .net core build error NETDSDK1061 and warning MSB3277

I’ve tried to find any help on that issue, finding some GitHub issues (e.g. this one) looking pretty similar, but were actually different. I’ve found a descriptive doc, but that didn’t really helped me. I found a pretty helpful blog post from Rick Strahl, explaining what packages are available and what the purpose of each … Read more

Run database migrations using Entity Framework core on application start

You can do this in the config methods in your Startup.cs. The simplest way is like this: public void ConfigureServices(IServiceCollection services) { services.AddDbContext<ApplicationDbContext>(); // add other services } public void Configure(IApplicationBuilder app, ApplicationDbContext db) { db.Database.Migrate(); // configure other services }