asp.net-core-2.0

What could cause `UserManager` to return the wrong user?

本小妞迷上赌 提交于 2019-12-28 19:28:09
问题 Something rather scary is happening on my ASP.NET Core 2.1.0 MVC site. While I was browsing, all of a sudden it shows I am logged in as a different user (who also happens to be browsing the site at that time). I can't pinpoint whether there is a specific use case that triggers this, but this has happened twice now. Navigating to other pages still shows I am logged in as the other user. It even seems I take over the claims of the user I am incorrectly logged in as. My question is: what could

ImageProcessor.Web on .Net Core 2.0 project

流过昼夜 提交于 2019-12-25 19:35:51
问题 Can i use the imageprocessor.Web on .net Core 2.0 project even if the it's restored, targeting .NETFramework, Version=v4.6.1? Update On a fresh .Net Core 2.0 project the following Packages where installed: imageprocessor imageprocessor.web imageprocessor.web.config Normally on a Asp.net Mvc Template (framework=v4.6.1) by creating simple markup for images such as <img alt="Picture for category Electronics" src="http://localhost:15536/images/thumbs/0000005_electronics_600.jpeg?crop=0.5,0,0,0.1

asp.net core 2.0 unable to delete PreCompiledViews.dll

北城余情 提交于 2019-12-25 15:52:24
问题 I have an asp.net core 2.0 web application. When I publish it to a web server (using a UNC path), the [AppName].PrecompiledViews.dll becomes locked and I'm unable to delete it (and therefore can't re-publish the app). I've tried manually deleting the file(s) - everything deletes fine, except for this one dll... and I don't have permission to go and restart the IIS worker process to free the lock, so I'm at a loss as to what to do... waiting for the app to recycle is my current best plan. Any

How to Map the results of Sql query onto Objects in Net Core2?

戏子无情 提交于 2019-12-25 03:22:47
问题 How can I map the results of a SQL command into a class object in Net Core, with SqlCommand() or FromSql()? Can someone update this answer for Net Core, or is the syntax still the same? How can I map the results of a sql query onto objects? 回答1: With EntityFramework Core, you simply use yourDbContextInstance.Set<T>().FromSql("your sql statement"); Where T is your class. However, your sql MUST return all the properties on your class. See documentation for more details on this. 来源: https:/

Serialize list of objects with JSON.NET in C#

不羁的心 提交于 2019-12-25 01:45:47
问题 I have a List that looks like: List<Product> products = new List<Product>(); Product p1 = new Product(1, "Apple", new Description("Red Apple")) Product p2 = new Product(2, "Banana", new Description("Yellow Banana")) products.Add(p1); products.Add(p2); A product looks like this: //Product model public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Description descriptions { get; set; } //Description model public string description { get; set } Now I want

Store and display HTML string while avoiding JS, in ASP.Net Core 2

依然范特西╮ 提交于 2019-12-25 01:33:49
问题 I wish to store a formatted text using a Rich-Text editor (QuillJS) and while displaying back it should be rendered as HTML. By default the views encode the HTML to avoid JS Injection, and so the data is being treated as a plain string. How do i manage to store and display / render the data as HTML, while at the same time filtering any JS in the string ? I tried searching for api's but couldn't find any help. Secondly, these days it's getting increasing difficult getting to the documentation

Hosting net core 2.0 app on iis gives internal server error

随声附和 提交于 2019-12-25 00:37:14
问题 I have a .net core web api application, on localhost it was working fine both on iis express and default iis. On my web server, I want to host my application as a sub-app under a Asp.Net v4.0 application. I have created a sub application and deployed my core app, then created a no managed app pool and chosen this app pool for my net core sub-app. I have fully installed .net core 2.0 windows hosting bundle and .net core 2.0 SDK. Web.config <?xml version="1.0" encoding="utf-8"?> <configuration>

Cannot get json data with ajax in Razor Pages [duplicate]

邮差的信 提交于 2019-12-24 22:53:42
问题 This question already has answers here : Example AJAX call back to an ASP.NET Core Razor Page (6 answers) Closed 2 years ago . i am trying to get some data from Razor Pages in ASP.NET Core 2.0. But the problem is that it does not returns any data. I also tried debugging it, it does not fire that method (OnGetProducts) at all. The model Index.cshtml.cs: private IProductRepository _productRepository; public IndexModel(IProductRepository repository) { _productRepository = repository; } public

IWebHostBuilder.GetSetting() doesnt have appsettings.json data

冷暖自知 提交于 2019-12-24 21:42:41
问题 I am working on refactoring an ASP.Net Core v1 application to v2. The gist of the current effort is moving the database seeding logic to Program.Main() as indicated in the MS docs... In 2.0 projects, move the SeedData.Initialize call to the Main method of Program.cs: The problem I am encountering is that I need to get a config flag out the appsettings.json file. This appears to be loaded by default when WebHost.CreateDefaultBuilder is called as per the source, but my code isn't able to

uploading and reading from an excel file in asp.net core 2

六眼飞鱼酱① 提交于 2019-12-24 21:23:18
问题 previously Asp.Net MVC had this third party library which easily allowed uploading and reading from an excel file called Excel Data Reader. We didn't need to have the file on the local disk, which was great because my application needs to run on Azure. However we are now porting this functionality to asp.net core 2, and it seems from searching that this is not possible. Does anybody know any libraries that would allow me to do this? Please note, I am not looking for solutions that read from a