asp.net-core-1.0

Typeconverter does not work in asp.net core

妖精的绣舞 提交于 2019-12-01 15:53:44
I have Amount stored in the database as decimal . I want to show that value on UI with thousand separator. I can add [DisplayFormat(DataFormatString = "{0:N2}", ApplyFormatInEditMode = true)] attribute on amount property and that would display number with thousand separator however when i POST the value back to server, the MVC model binding would not work because of commas. I have created a custom type converter that converts from decimal to string and then string to decimal public class NumberConverter : TypeConverter { public override bool CanConvertFrom( ITypeDescriptorContext context, Type

ASP.NET Core 1.0 - MVC 6 - Cookie Expiration

非 Y 不嫁゛ 提交于 2019-12-01 14:45:11
UPDATE: It is definitely not a bug in RC1. The cookie settings are working with the default UserManager and UserStore, so it must be something related to my UserManager/UserStore, I've overseen. I basically use the implementation here: https://github.com/jesblit/ASPNET5-FormAuthenticationLDAP Original Post: I have a problem with persistent logins. No matter how I configure the cookie, after 30 minutes, the User is automatically logged out (no matter how much the user interacts with the App). I setup my App with: public void ConfigureServices(IServiceCollection services) { services.AddCaching()

ASP.NET Core 1.0 - MVC 6 - Cookie Expiration

前提是你 提交于 2019-12-01 13:19:58
问题 UPDATE: It is definitely not a bug in RC1. The cookie settings are working with the default UserManager and UserStore, so it must be something related to my UserManager/UserStore, I've overseen. I basically use the implementation here: https://github.com/jesblit/ASPNET5-FormAuthenticationLDAP Original Post: I have a problem with persistent logins. No matter how I configure the cookie, after 30 minutes, the User is automatically logged out (no matter how much the user interacts with the App).

How to read xml document in MVC core (1.0.0)?

99封情书 提交于 2019-12-01 11:09:44
I'm new to web programming and decided to switch from .net 4.5 to .net core. My project has a static xml document in the following location: wwwroot/Countries/en-GB.xml How would one go about reading the xml file at the specified path? Eventually I will convert the data to a SelectList. In .net 4.5 I used DataSet's and HttpConext...MapPath to read the xml document which no longer works in core mvc. Any advice is greatly welcome. First of all don't put your data source into wwwroot folder, because it is served publicly. Take a look at official docs : The web root of your app is the directory in

Working with IViewLocationExpander in mvc

余生长醉 提交于 2019-12-01 09:28:50
I want to render the view from custom location, so for that I have implemented IViewLocationExpander interface in a class. I have registered the same class in startup file as follows. Startup.cs file public void ConfigureServices(IServiceCollection services) { ..... //Render view from custom location. services.Configure<RazorViewEngineOptions>(options => { options.ViewLocationExpanders.Add(new CustomViewLocationExpander()); }); .... } CustomViewLocationExpander Class public class CustomViewLocationExpander : IViewLocationExpander { public IEnumerable<string> ExpandViewLocations

Create RSS feed in asp.net core 1.0

…衆ロ難τιáo~ 提交于 2019-12-01 09:09:22
I am working in Asp.net Core 1.0 MVC 6 I am trying to write a component to provide RSS feeds from my websites. I found this post that suggests that System.ServiceModel.Syndication has yet to be ported to ASP.NET CORE. I am unable to target the full .NET framework. The suggestion is to write as an xml parser. I am however struggling to get my head around everything that might be required. I have built the functionality to get my data into XML but now need to better understand how to allow this to be called from an IActionResult (or indeed how to generate a link that may be placed on my page). I

Working with IViewLocationExpander in mvc

偶尔善良 提交于 2019-12-01 07:09:11
问题 I want to render the view from custom location, so for that I have implemented IViewLocationExpander interface in a class. I have registered the same class in startup file as follows. Startup.cs file public void ConfigureServices(IServiceCollection services) { ..... //Render view from custom location. services.Configure<RazorViewEngineOptions>(options => { options.ViewLocationExpanders.Add(new CustomViewLocationExpander()); }); .... } CustomViewLocationExpander Class public class

Custom 401 and 403 response model with UseJwtBearerAuthentication middleware

依然范特西╮ 提交于 2019-11-30 18:40:32
I want to respond with a JSON response model when a 401 and 403 occur. For example: HTTP 401 { "message": "Authentication failed. The request must include a valid and non-expired bearer token in the Authorization header." } I am using middleware (as suggested in this answer ) to intercept 404s and it works great, but it is not the case with 401 or 403s. Here is the middleware: app.Use(async (context, next) => { await next(); if (context.Response.StatusCode == 401) { context.Response.ContentType = "application/json"; await context.Response.WriteAsync(JsonConvert.SerializeObject

The dependency Microsoft.Composition 1.0.27 does not support framework .NETCoreApp,Version=v1.1

橙三吉。 提交于 2019-11-30 18:34:09
When I upgrade framework section to: "frameworks": { "netcoreapp1.1": { "dependencies": { }, "imports": "dnxcore50" } } I am getting error The dependency Microsoft.Composition 1.0.27 does not support framework .NETCoreApp,Version=v1.1. With "Microsoft.VisualStudio.Web.CodeGeneration.Tools" : underlined Microsoft.Composition supports .NET Framework 4.5, Windows 8 and WindowsPhone 8.1 among other targets, this means it should work. But it doesn't target netstandard1.x specifically neither does it netcoreapp1.x , so you need to tell nuget via the import section to also restore PCL Libraries which

connection string in asp.net core library project

夙愿已清 提交于 2019-11-30 17:45:55
问题 I have asp.net core library project. I want to add connection string in it. I don't have startup class in this. Where I need to place connection string and how to fetch it? Please suggest. 回答1: In dotnet core you can manage configuration using json files, which is one in many ways to configure your application. According to the dotnet core configuration documentation you can simply do (copied from link reference) using Microsoft.Extensions.Configuration; using System; using System.IO; // Add