asp.net-core-mvc

How to use Microsoft.Extensions.Configuration.IConiguration in my XUnit unit testing

寵の児 提交于 2019-12-02 06:04:29
问题 In my Asp.net Core 2.0 application, I am trying to unit test my data service layer (.Net Standard Class Library) that uses the Microsoft.Extensions.Configuration.IConfiguration dependency injection. I am using XUnit and don't know how to pass IConfiguration from my unit test class. I tried the following implementation and getting the error Message: The following constructor parameters did not have matching fixture data: IConfiguration configuration. I am really new to the testing frameworks

Missing CloudTable.Execute (and all non-async methods) in ASP.Net 5 Projects

非 Y 不嫁゛ 提交于 2019-12-02 05:53:57
问题 Using Microsoft Visual Studio 2015 RC, if I create a new "ASP.Net Web Application", and go to NuGet and add a reference to the latest version of Azure Storage (Install-Package WindowsAzure.Storage -Pre), in the CloudTable class, all I see are the *Async methods: However, if I create a new Console Application or Class Library (normal class library and console application, not a "Package" one) then I see all the methods as I expect: And it isn't just intellisense, the methods seem to actually

“Cannot find compilation library location for package ”enc.dll“” error occur .net core dependency injection

拈花ヽ惹草 提交于 2019-12-02 05:04:28
问题 I am building a website using asp.net core mvc, and for the login i added dependency for enc.dll file, which just encrypt/decrypt user information. I made a Seeder class with enc.dll file, which has a key property and en/decrypt with the key. Then I added it to my service to use dependency injection feature. services.AddSingleton<ISeeder, Seeder>(); While it works well when i call enc, dec function of seeder class, it does not return any error. Below is the example code. private readonly

How to use yarn in ASP.Net core MVC to install bootstrap in wwwroot folder

守給你的承諾、 提交于 2019-12-02 04:26:11
recently I started learning ASP.Net core MVC. I always used bower to install packages for my projects in Visual Studio 2017. but now I want to use yarn. since it seems bower is deprecated. but I don't know how to use yarn to install bootstarp in wwwroot folder. for bower i used bower.json and it would install bootstarp automatically. I use "yarn add bootstrap@4.0.0-alpha.6 --dev" but it install it in node_modules in the project folder and I can't see it in the solution explorer, thanks It's best to use npm(a package manager) for Asp.net core application,start by searching and adding a package

Add Assemblies to Visual Studio 2015 ASP.NET 5

对着背影说爱祢 提交于 2019-12-02 04:18:17
问题 I want to add "Stimulsoft.Report.dll" as an assembly in my Visual Studio 2015 ASP.Net 5 project. But the reference manager does not contain the assemblies section with the extentions area(as it is in VS 2013), where i could select "Stimulsoft.Report" and add this to my references. Is there any solution adding these reference to my ASP.NET 5 project? 回答1: you can add the assembly if it available in GAC like below code "frameworks": { "aspnet50": { "frameworkAssemblies": { "Stimulsoft.Report":

Create/Get DefaultHtmlGenerator from MVC Controller

余生颓废 提交于 2019-12-02 03:39:50
问题 I am trying to create(Or get an instance of it somehow) for Microsoft.AspNet.Mvc.Rendering.DefaultHtmlGenerator inside my MVC6 controller method I wanted to generate the html for validation for my Model my self inside my controller of asp.net mvc. My issue is where to get the constructor data for DefaultHtmlGenerator like antiforgery, metadataProvider..etc [HttpGet] public IActionResult GetMarkup() { // IHtmlGenerator ge = this.CurrentGenerator(); IHtmlGenerator ge = new DefaultHtmlGenerator

How to reference .NET framework from ASP.NET Core

∥☆過路亽.° 提交于 2019-12-02 03:25:50
问题 I have a ASP.NET MVC 5 / .NET 4.7 project that I want to upgrade to ASP.NET Core. The MVC frontend references a service layer project (SL) which in its that uses a datalayer (DAL) project built using Entity Framework. Our assessment is that Entity Framework Core is still missing features that we need and that we should not upgrade the DAL project to .NET Core. What framework should my projects target to be able to work together? Can we upgrade just one project to .NET Core and keep the rest

How to use ConfigurationBinder in Configure method of startup.cs

不问归期 提交于 2019-12-02 03:14:25
问题 asp.net mvc 6 beta5 I've tried to use config.json to activate\disactive logging public IConfiguration Configuration { get; set; } public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv) { var configurationBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); Configuration = configurationBuilder.Build(); DBContext.ConnectionString = Configuration.Get("Data:DefaultConnection:ConnectionString"); } public void

ASP.NET Custom Model Binding: DateTime

落爺英雄遲暮 提交于 2019-12-02 03:12:55
问题 The problem At this point I have a problem where my Get action is trying to read a DateTime parameter in a diferent format that is sent. While the DateTime sent has this format: 0:dd/MM/yyyy The Get Actions expects: 0:MM/dd/yyyy The solution (maybe) In order to change what the Get action is expecting I'm using a Custom Model Binding. The GET Action public async Task<IActionResult> Details(int? id, [ModelBinder(typeof(PModelBinder))]DateTime date) The ModelBinder class Now here are a few

How to use Microsoft.Extensions.Configuration.IConiguration in my XUnit unit testing

穿精又带淫゛_ 提交于 2019-12-02 03:07:27
In my Asp.net Core 2.0 application, I am trying to unit test my data service layer (.Net Standard Class Library) that uses the Microsoft.Extensions.Configuration.IConfiguration dependency injection. I am using XUnit and don't know how to pass IConfiguration from my unit test class. I tried the following implementation and getting the error Message: The following constructor parameters did not have matching fixture data: IConfiguration configuration. I am really new to the testing frameworks and don't even know if dependency injection can be used as I am trying to do in my code snippet. My Unit