asp.net-core-1.0

No service for type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory' has been registered

点点圈 提交于 2019-11-30 00:11:52
问题 I'm having this problem: No service for type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory' has been registered. In asp.net core 1.0, it seems that when the action try to render the view i have that exception. I've searched a lot but I dont found a solution to this, if somebody can help me to figure out what's happening and how can I fix it, i will appreciate it. My code bellow: My project.json file { "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0", "type":

Pass parameter to Partial View in ASP.NET Core

∥☆過路亽.° 提交于 2019-11-29 19:30:40
问题 On an ASP.NET Core 2.0 application I need to render a partial view and pass a few parameters: @Html.Partial("Form", new { File = "file.pdf" }) On the partial view I tried to access it using: @Model.File And I get the error: RuntimeBinderException: 'object' does not contain a definition for 'File' If I simply use on my partial: @Model I get the following printed on the page: { File = file.pdf } So there the model is being passed and there is a property File in it. So what am I missing? 回答1:

How to validate XML in .NET Core 1.1.2

十年热恋 提交于 2019-11-29 17:31:42
How can i validate XML against XSD schema in .NET Core 1.1.2? i found this ms docs but i cannot use it with .NET core 1.1.2 using System; using System.Collections.Generic; using System.Text; using System.Xml; using System.Xml.Schema; namespace MyNameSpace { public static class XmlValidation { public static void Validate(string schema, string xml) { XmlReaderSettings schemaSettings = new XmlReaderSettings(); schemaSettings.Schemas.Add(schema); schemaSettings.ValidationType = ValidationType.Schema; schemaSettings.ValidationEventHandler += new ValidationEventHandler(ValidationEventHandler);

Solving error “Microsoft.NETCore.App 1.0.0 does not support framework .NETFramework,Version=v4.6.1”

北城余情 提交于 2019-11-29 17:19:47
问题 I have an ASP.NET Core 1.0 complete application running using net461 references. Now I am trying to add another framework - netcoreapp1.0 . For this, I have updated my project.json like this: { "userSecretsId":"", "version":"2.4.0-*", "buildOptions":{ "emitEntryPoint":true, "preserveCompilationContext":true }, "dependencies":{ "Microsoft.ApplicationInsights.AspNetCore":"1.0.0", "Microsoft.AspNetCore.Authentication.Cookies":"1.0.0", "Microsoft.AspNetCore.Diagnostics":"1.0.0", "Microsoft

RequireHttpsAttribute with .NETCore RC2 causes HTTP302 redirect loop on Azure

随声附和 提交于 2019-11-29 16:56:37
I've been trying to get a .NETCore RC2 web app working on Azure with the RequireHttpsAttribute set but I'm having issues. To remove the possibility of this being a problem that I've introduced with my code, I cut things back to the bare minimum and recreated it using the "out of box" VS2015 .NETCore RC2 template. If I deploy the standard VS2015 .NETCore RC2 web app the site runs fine. If I then add [RequireHttps] to the controllers it works fine locally, but on Azure it causes an HTTP302 redirect loop. This seems to be something which has changed since RC1 since the RequireHttpsAttribute works

EntityFramework code first: Set order of fields

早过忘川 提交于 2019-11-29 16:16:29
问题 I am using EntityFramework with the "Code first" approach with migrations. I have successfully generated tables from my models, but the columns are being added in an alphabetical order rather than the order inside my model. I have tried this: [Key, Column(Order=0)] public int MyFirstKeyProperty { get; set; } [Column(Order=1)] public int MySecondKeyProperty { get; set; } But that doesn't seem to be working. How can I manually set the order of the fields in the database? I am using ASP.NET Core

Value cannot be null. Parameter name: connectionString appsettings.json in starter

拟墨画扇 提交于 2019-11-29 13:12:14
I am trying to write my connection string in my appsettings.json file and bring it into my startup file but I keep getting a Value cannot be null. Parameter name: connectionString. I have been using various examples but can't seem to see this new setup with ASP.NET 1.0 Core startup class. Appsetting.json file: { "Data": { "DefaultConnection": { "ConnectionString": "Data Source=server;Initial Catalog=dbase;Trusted_Connection=True;MultipleActiveResultSets=true" }, "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } } } }

Asp.Net core get RouteData value from url

北城以北 提交于 2019-11-29 10:51:59
问题 I'm wokring on a new Asp.Net core mvc app. I defined a route with a custom constraint, which sets current app culture from the url. I'm trying to manage localization for my app by creating a custom IRequestCultureProvider which looks like this : public class MyCustomRequestCultureProvider : IRequestCultureProvider { public Task<ProviderCultureResult> DetermineProviderCultureResult(HttpContext httpContext) { var language= httpContext.GetRouteValue("language"); var result = new

Form submit resulting in “InvalidDataException: Form value count limit 1024 exceeded.”

可紊 提交于 2019-11-29 10:48:56
问题 I have created an mvc site and I'm posting a large amount of json form data ( Content-Type:application/x-www-form-urlencoded ) back to the mvc controller. When I do this, I receive a 500 response that states: "InvalidDataException: Form value count limit 1024 exceeded." In previous versions of aspnet, you would add the following to the web.config to increase the limit: <appSettings> <add key="aspnet:MaxHttpCollectionKeys" value="5000" /> <add key="aspnet:MaxJsonDeserializerMembers" value=

Read appsettings.json in Main Program.cs

帅比萌擦擦* 提交于 2019-11-29 10:47:30
问题 First of all my main purpose is to setup the IP and Port for my application dynamically. I'm using IConfiguration to inject a json config file, like some tutorial mentioned. However, I can't retrieve the configuration in Program.cs, because my WebHostBuilder will use the StartUp and Url at the same time. So at the time the host build up, there is nothing in my configuration. WebProtocolSettings settings_Web = new WebProtocolSettings(); var host = new WebHostBuilder() .UseIISIntegration()