asp.net-core-1.0

“The type or namespace name could not be found” in ASP.NET Core 1.0 RC2

社会主义新天地 提交于 2019-12-23 09:42:04
问题 I'm currently trying ASP.NET Core 1.0 RC2. I've created it as a .NET Framework project (as opposed to a .NET Core project) and added references to our Models library, using .NET Framework 4.5, via a project reference: "frameworks": { "net46": { "dependencies": { "Project.Core": { "target": "project" }, "Project.DataAccess": { "target": "project" }, "Project.Encryption": { "target": "project" }, "Project.Models": { "target": "project" }, "Project.Resources": { "target": "project" } } } }, Now

Proper way to prevent Angular2 http request caching in internet explorer (IE)

僤鯓⒐⒋嵵緔 提交于 2019-12-23 07:48:34
问题 I have a well-known problem when IE Caches ajax requests In JQuery we have $.ajaxSetup({ cache: false }); Most common solution is to change url on each request... However is there any angular2-specific solution for this problem? using Angular2 and asp.net core 回答1: There is no native support of this within Angular2. You need to implement this by your own. A possible approach would be to implement an HTTP interceptor and append a timestamp if the request with the URL has already been executed.

How to get information about runtime .Net Core

北战南征 提交于 2019-12-22 07:01:57
问题 I have an app which works on Linux and Windows. I need to know where the app is working for use difference code. Thanks 回答1: You are probably looking for System.Runtime.InteropServices.RuntimeInformation with the IsOsPlatform function to do runtime checks. Have look at the video tutorial https://channel9.msdn.com/Series/aspnetmonsters/ASPNET-Monsters-Episode-46-Finding-Platform-Information of the ASP.NET Monsters. 来源: https://stackoverflow.com/questions/39207282/how-to-get-information-about

.NET Core 1.0, Enumerate All classes that implement base class

杀马特。学长 韩版系。学妹 提交于 2019-12-22 05:27:25
问题 I am working on migrating an ASP.NET project to RC2. I am using AutoFac to try to enumerate classes that implement AutoMapper Profile base class to set up all my mapping profiles without having to call them explicitly. Previously in older version of ASP.NET (even in RC1) I was able to use the following code: public class AutoMapperModule : Module { protected override void Load(ContainerBuilder builder) { builder.RegisterAssemblyTypes().AssignableTo(typeof(Profile)).As<Profile>(); builder

Glimpse diagnostics platform which is full compatible to ASP.NET Core

妖精的绣舞 提交于 2019-12-22 05:14:51
问题 I used Glimpse on the old ASP.NET MVC5 stack and liked it very much cause it gives a pretty and detailed representation of nearly all important data for debugging purpose. Sadly, its not compatible with ASP.NET Core (yet). I tried to install the demo, which assurance to work with ASP.NET Core. But thats not entirely true cause it works on ASP.NET Core, but depends on the old 4.x framework. So it destroys the cross-platform compability, which is not suiteable for me. The app is designed to run

ActionContext gone in Microsoft.AspNetCore.Mvc.Controller

烂漫一生 提交于 2019-12-22 04:44:29
问题 I cant find ActionContext in Microsoft.AspNetCore.Mvc.Controller after i changed my Version to AspNetCore 1.0.0-preview1 this is Controller class (after Change): And from " Microsoft.AspNet.Mvc " before change : and code from old method before update : this.Agent = ControllerInfo.Request.Headers["User-Agent"]; this.IP = ControllerInfo.HttpContext.Features.Get<IHttpConnectionFeature>()?.LocalIpAddress?.ToString(); this.RemoteIP = ControllerInfo.HttpContext.Features.Get<IHttpConnectionFeature>(

Is there any replace of AssemblyBuilder.DefineDynamicAssembly in .NET Core?

做~自己de王妃 提交于 2019-12-22 01:12:13
问题 How to port the following code to .Net Core: AppDomain.CurrentDomain.DefineDynamicAssembly( new AssemblyName( Guid.NewGuid().ToString()), AssemblyBuilderAccess.RunAndSave); Is it possible? 回答1: add this to your project.json "dependencies": { "System.Reflection.Emit": "4.0.1" }, and use AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(Guid.NewGuid().ToString()), AssemblyBuilderAccess.Run); AssemblyBuilderAccess.RunAndSave is not supported at the moment link to souce. Update: For new

Custom 404 response model

主宰稳场 提交于 2019-12-22 00:25:35
问题 I want to provide a custom reponse for all 404s on our API. For example: { "message": "The requested resource does not exist. Please visit our documentation.." } I believe the following result filter works for all cases within the MVC pipeline: public class NotFoundResultFilter : ResultFilterAttribute { public override void OnResultExecuting(ResultExecutingContext context) { var result = context.Result as NotFoundResult; if (result != null) { context.Result = new HttpNotFoundResult(); // My

Create an User in a Console .NET Core Application

a 夏天 提交于 2019-12-21 04:55:05
问题 I have a ASP.NET Core 1.0 Solution with 3 projects (Web, Console Application, DataAccessLayer). I use ASP.NET Core Identity and Entity Framework Core (SQL Server - Code First). In my Console Application (Used for background tasks), I want to create users, but how I can have access to UserManager object in a Console Application (Or in a .NET Core Class Library) ? In a controller class, it's easy with Dependency Injection : public class AccountController : Controller { private readonly

Cookies in ASP.NET Core rc2

老子叫甜甜 提交于 2019-12-20 02:50:06
问题 Can someone pls explain how to store and get cookies in an ASP.NET Core rc2 application? I can only find outdated information about the old HttpContext.Response.Cookies.Get and Add methods, neither of which still exist in Core. Also, the HttpCookie class doesn't seem to exist either. What is the new cookie class and how can I get and add one? (Note: I am not specifically taking about authentication cookies, just general data cookies) 回答1: For getting request cookie value: HttpContext.Request