Posts

Showing posts with the label asp.net-core-mvc

Vue.js and structuring multi-page web apps - component registrations

Vue.js and structuring multi-page web apps - component registrations I want to use Vue.js for a MVC Core 2.1 multi-page web app, but I think my approach is a bit quirky. I have searched a lot for a better way to structure my code. I also took a look at how PHP Laravel 5.x does it, and it seems like they take the same approach as the one I use, kinda. I have created a main.js file where I register some of the components globablly, and the ones that are only used by specific components will of course be registered only locally. So, basically every page will have it's own component registered gloablly... (btw I use Webpack) main.js import Vue from 'vue'; import Axios from 'axios'; import BaseLayout from './components/layout/BaseLayout.vue'; import BaseHeaderLayout from './components/layout/BaseHeader.vue'; import HomeIndex from './components/home/Index.vue'; import HomeCreate from './components/home/Create.vue'; import 'bootstrap/d...

Restore AJAX handling for ASP.NET Core to previous functionality

Image
Restore AJAX handling for ASP.NET Core to previous functionality In previous MVC5 and below, you could make an ajax call that unwrapped the parameters properly: JS: $.post('/controller/endpoint',{intparam: 1, strparam: 'hello'}) CS: public ActionResult endpoint(int intparam, string strparam){} In the new aspnetcore, it has changed: CS: public CustomClassWrapper{ public int intparam {get;set;} public string stringparam {get;set;} } public ActionResult endpoint([FromBody]CustomClassWrapper item){} To sum it up, in the new framework, you need to write a wrapper class and can only pass one [FromBody] parameter to the method. Previously, the params would be unwrapped by variable name correctly. So, i'm trying to re-implement this functionality in an aspnetcore middleware component. I'm having difficulty in how to accomplish calling the controller method properly with the parameters. My current cut-down code: public async Task Invoke(HttpContext context) ...

Asp.Net Core API disable startup complete message

Image
Asp.Net Core API disable startup complete message As part of my application I have a .Net Core API project. Unlike most cases where this project would run as its own process, I have the API run in a thread, among others, in a single process. Also for my project, I have implemented a custom logging system to suit my needs. However, I have come across a slight problem. Every time I run my program, once the API starts, this message is printed to the console: Hosting environment: Production Content root path: C:UsersPathToCode Now listening on: http://*:8000 Application started. Press Ctrl+C to shut down. I would like to disable this message as there is no need for it, and it clutters up the otherwise well organized console log. I have a screenshot below so you know exactly what I'm talking about: I have already disabled all other logging for the mvc (removed ILoggerFactory from ConfigureServices and set all logging to "None" in appsettings.json ). ILoggerFactory ConfigureS...