asp.net-core-mvc

How to add js and css files in ASP.net Core?

风格不统一 提交于 2020-07-02 08:14:07
问题 I've been assigned to migrate an application from MVC into ASP.net Core, I'm new to ASP.net Core. In MVC we have BundleConfig.cs and in there we add references to our css and js files, how does it work in ASP.net Core? Let's say that I created a test.js and a MyStyle.css class, which is the best way to add references to it in every view? Should I place the .js and .css files inside wwwroot/js and wwwroot/css ? 回答1: I added the references inside the _Layout view, inside the <environment> tags:

When creating an asp.net core with Work and accounts, do we need to register our application inside azure or microsoft

混江龙づ霸主 提交于 2020-06-29 04:44:08
问题 I have created a new asp.net core MVC and i select the Work or School Account with Multiple Organization, as follow:- now when i run my application inside visual studio i were able to login using my office 365 account, which is great. but my question is, when i deploy then web application inside a live iis , can i still login using my office 365 account? or i need to register my application inside azure or inside Microsoft first? or the login will be offered for us without any extra work? 回答1

using System.Drawing.Imaging; Imaging does not exist in the System.Drawing

≡放荡痞女 提交于 2020-06-28 03:50:41
问题 I am attempting to pull metadata from photos in a .Net Core App by using this library: https://www.codeproject.com/Articles/27242/ExifTagCollection-An-EXIF-metadata-extraction-libr However while implementing the ExifTagCollection class I am getting the Error listed in the title. I have successfully referenced System.Drawing but it is not recognizing its drawing extension. Any help would be great. Also open to suggestions for other libraries to accomplish my goal. Thx 回答1: If you take a look

using System.Drawing.Imaging; Imaging does not exist in the System.Drawing

百般思念 提交于 2020-06-28 03:50:11
问题 I am attempting to pull metadata from photos in a .Net Core App by using this library: https://www.codeproject.com/Articles/27242/ExifTagCollection-An-EXIF-metadata-extraction-libr However while implementing the ExifTagCollection class I am getting the Error listed in the title. I have successfully referenced System.Drawing but it is not recognizing its drawing extension. Any help would be great. Also open to suggestions for other libraries to accomplish my goal. Thx 回答1: If you take a look

Is it possible to register more than one user with Asp.Net Identity core?

久未见 提交于 2020-06-27 17:25:05
问题 I know by creating an user service with entity framework and creating a password hash i can add one or more users to the website! but i'd like to use asp.net identity features even when i want to register batch users (like upload users list with excel or xml file). In my scenario i want register more than one users on the website by uploading users list in xml,json or excel file. And i want to register all of them in one transaction. Has anyone idea? 回答1: Depends at what level of abstraction

Anchors with asp-controller and asp-action attribute don't get rendered as links

≡放荡痞女 提交于 2020-06-27 13:17:15
问题 In this Razor syntax: <a asp-controller="Home" asp-action="Index">Home</a> @foreach (LinkNodeModel link in Model.ControlActions) { link.LinkTree(); } The "Home" link renders just fine, but the manually rendered <a> strings don't get turned into a valid link. LinkTree() is implemented like this: return $"<a asp-controller=\"{Controller}\" asp-action=\"{Action}\">{Name}</a>"; When I print the links with the @link.LinkTree() , the output contains a line with just the code displayed, which doesn

How to register dependency injection with generic types? (.net core)

纵饮孤独 提交于 2020-06-27 10:41:09
问题 I have an asp.net core web app with multiple parameters in appSettings.json file. I didnt' want to have services having IOptions<MyObject> in the constructor. I wanted MyObject in the constructor. So I found the following article: https://weblog.west-wind.com/posts/2017/dec/12/easy-configuration-binding-in-aspnet-core-revisited which is very interesting. But I want to go further. I would like to create an extension method to generate the injection. Here is what I would like to do: using

Net Core NLog.Web “aspnet-user-identity” is empty?

吃可爱长大的小学妹 提交于 2020-06-27 08:16:40
问题 I was using "NLog.Extensions.Logging" for logging and need to log user identity and found that it is possible with "NLog.Web.AspNetCore". "nlog.config" file is configured to log the "aspnet-user-identity". However, when I look at logs, user identity part is always empty string, the other columns are look pretty good. Am I missing something? A part of my configuration file is here: <extensions> <assembly="NLog.Web.AspNetCore" /> </extensions> <parameter name="@identity" layout="${aspnet-user

Net Core NLog.Web “aspnet-user-identity” is empty?

ぐ巨炮叔叔 提交于 2020-06-27 08:16:40
问题 I was using "NLog.Extensions.Logging" for logging and need to log user identity and found that it is possible with "NLog.Web.AspNetCore". "nlog.config" file is configured to log the "aspnet-user-identity". However, when I look at logs, user identity part is always empty string, the other columns are look pretty good. Am I missing something? A part of my configuration file is here: <extensions> <assembly="NLog.Web.AspNetCore" /> </extensions> <parameter name="@identity" layout="${aspnet-user

How to change root path ~/ in Razor in asp.net core

£可爱£侵袭症+ 提交于 2020-06-25 08:54:08
问题 The simplest question for which I can't find an answer. I have an asp.net core 2.1 MVC application with Razor. Application widely uses ~/path syntax. Everything works great if application runs from domain root (for example, from http://localhost:5000/) But when I run application at non-root (for example, http://localhost:5000/app) the Razor still uses root ( / ) as base path. Question: how to configure this? How to specify base path for Razor's ~/ ? There must be an environment variable for