Posts

Showing posts with the label AspnetCore

Handling Raw Html

For sometime now I've been at a point in my research to find the proper way to handle raw html. Sometimes you need your api to push raw html with syntax that can't be edited once its submitted.  Handling all html in a 2D array where the first in just the html tag and the second is a child's value which can also be a html tag. { ["p"]["test"]  This may also be another case to start my project with a headless orchard core project. Using fluid syntax might be the better way to allow an api to take information and using a custom javascript library to convert html to the api? 

Aspnet Dotnet Notes: Custom Authorization & App_Data

Trying to handle a secure folder  where the files are not pushed to the server at deploy. Like all files in wwwroot they are in source control, these will not. The files I'm storing are so big that moving them is a separate process do outside of my application. https://stackoverflow.com/questions/36775942/how-do-i-serve-static-files-only-to-authorized-users https://github.com/ClintBailiff/MiddlewareDemo/blob/master/Startup.cs get current user   inside an MVC controller: From the  Controller  base class, you can get the  IClaimsPrincipal  from the  User  property System . Security . Claims . ClaimsPrincipal currentUser = this . User ; You can check the claims directly (without a round trip to the database): bool IsAdmin = currentUser . IsInRole ( "Admin" ); var id = _userManager . GetUserId ( User ); // Get user id: Other fields can be fetched from the database's User entity: Get the user manager using dependency injection private

Dynamically sitemap.xml in Aspnet Core

Someday I'd like to complete this project but for now I have very little time so I'll just hold onto these notes. The goal or idea would be for me to create a SEO friendly site but with all my experience with cms or spa applications I'd create it more based on a headless cms. If I get the chance I'd want to work with orchard core on this. Notes https://stackoverflow.com/questions/50311264/how-to-create-dynamically-sitemap-xml-in-net-core-2 https://rehansaeed.com/dynamically-generating-sitemap-xml-for-asp-net-mvc/ https://github.com/uhaciogullari/SimpleMvcSitemap#google-sitemap-extensions

Aspnet: IncludeScopes for Providers

On a previous job I had this in my appsettings.json,      {     "Logging": {         "IncludeScopes": false,         "LogLevel": {           "Default": "Information",           "Microsoft": "Warning",           "Microsoft.AspNetCore": "Warning",           "Microsoft.Hosting.Lifetime": "Trace"         }       }     } Getting a warning message, "logging configuration for provider. The provider name must match the configuration's json property name." This doesn't help me understand why its looking warning for an object. If it helps I'm using nlog but this warning still appears even if I remove nlog. After writing this I found the docs here:  Logging in .NET Core and ASP.NET Core And the following fixes my warning:      "Logging": {         "Console": {           "IncludeScopes": false         },         "LogLevel": {  

NLog Killing Aspnet Core Application

Image
Awhile back I moved to a new location for storing my server and for the most part things went smoothly. Didn't have any issues with my local DNS or emails, however I did encountered one issue. The issue was Recycled Motors where the application would boot but instantly fail. Which didn't create any logs or errors for me to look. So it took me a few weeks along with everything else going on to figure this one out. I spend a little too much time looking into my network and the bind9 configs because I know it had to do with my configs. Originally I was on a 10.0.10.x network but with the I.P. the modem only allowed the regular 192.168.1.x ip address. Eventually I figured out the issue, being my NLog config itself. I have it writing in a database where I list the ip address explictly. I completely forget about this since it was just a quick thing I added a few weeks before the move and I still have it pointed to localhost in the appsettings.json Solutions Use different envir

.NET Core Docker Image for SPA Applications

If your looking to get CI/CD up and running with a SPA Application I recommend this setup. This article is based on Aspnet Core 2.1 and up. If you read the docker docs on the 2.1 version of dotnet core you will see they removed nodejs, which breaks a bunch of stuff if your using dotnet core with either Angular2 or Reactjs. I currently use gitlab-runners but with the volumes config to publish my sites. Notes from Dotnet Using NodeJS in  microsoft/aspnetcore-build , but this is missing from  dotnet/core/sdk:2.1 . What should I do? You can either install NodeJS by adding a few lines of code to your Dockerfile that download and extract NodeJS, or you can use the multi-stage feature of Docker and the official NodeJS images. Sample code to install NodeJS on your own: # set up node ENV NODE_VERSION 8.9.4 ENV NODE_DOWNLOAD_SHA 21fb4690e349f82d708ae766def01d7fec1b085ce1f5ab30d9bda8ee126ca8fc RUN curl -SL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x

Popular posts from this blog

UI-Bootstrap Collapsible Sticky Footer

Installing Windows on Acer chromebook 15 cb3-532

Aspetcore: NLog with Postgresql