asp.net-core-mvc

Modify CookieAuthenticationOptions LoginPath OnRedirectToReturnUrl Event

自闭症网瘾萝莉.ら 提交于 2019-12-22 06:59:53
问题 I have the following setup in my MVC 6 ASP.NET 5 project: Startup.cs in the Configure Method: app.UseCookieAuthentication(options => { options.AuthenticationScheme = "Cookie"; options.LoginPath = new PathString("/<TENANT>/account/signin/"); options.AccessDeniedPath = new PathString("/<TENANT>/account/unauthorised/"); options.AutomaticAuthenticate = true; options.AutomaticChallenge = true; options.Events = new CookieAuthenticationEvents { OnRedirectToReturnUrl = MyClass

ASP.NET Core 2.2 JWT Authentication

帅比萌擦擦* 提交于 2019-12-22 06:51:09
问题 I've been learning about ASP.NET Core 2.2 recently and trying to develop a Role-Based login sample(Website + Web API) using JWT token. Definition is simple: if user's role is "admin" then it redirects to admin page. if user's role is "user" then it redirects to user page. But most of the solutions and articles I found on "JWT token with ASP.NET Core 2.2" is only for Web API. I've almost understood how JWT token works and how to implement it on Web API side from following article : http:/

Serve static files outside wwwroot, but handle PhysicalFileProvider when directory does not exist

时光总嘲笑我的痴心妄想 提交于 2019-12-22 06:46:29
问题 I am trying to serve files from outside wwwroot but also handle a setup situation where the directory may not exist yet. For example, if I built a site which relies on this directory, but a user did not follow install instructions and create the directory first. For the sake of argument, let's pretend I want a simple website which has a page that will read the contents of that directory and display some files. This page might also allow you to download files from /Documents subdirectory. The

Publish to Azure fails with “ Unrecognized link extension 'contentLibExtension'” Error

雨燕双飞 提交于 2019-12-22 06:15:27
问题 I am trying to publish ASP.NET MVC 6 App to Azure with Visual Studio 2015 CTP. And getting the following error Publishing with publish method [MSDeploy] Calling msdeploy with the command: ["C:\Program Files (x86)\IIS\Microsoft Web Deploy\msdeploy.exe" -source:IisApp='C:\Users\*****\AppData\Local\Temp\AspNetPublish\NgCalendar-28\wwwroot' -dest:IisApp='ngcalendar',ComputerName='https://ngcalendar.scm.azurewebsites.net/msdeploy.axd',UserName='$ngcalendar',Password='{PASSWORD-REMOVED-FROM-LOG}'

A DbContext instance cannot be used inside OnConfiguring since it is still being configured at this point

喜夏-厌秋 提交于 2019-12-22 06:09:29
问题 I'm trying to build a custom view location system. public class myViewLocationExpander : IViewLocationExpander { private myDBContext _context; public myViewLocationExpander (myDBContext context) { _context = context; } public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations) { _context.Property.//..... //Error happened here Some other codes } And in my startup file public void ConfigureServices(IServiceCollection services) { /

ASP.NET Core MVC App Settings

淺唱寂寞╮ 提交于 2019-12-22 05:42:06
问题 I'm trying to use configuration variables on my ASP.NET Core MVC project. This is where I've got so far: Created an appsettings.json Created an AppSettings class Now I'm trying to inject it on the ConfigureServices, but my Configuration class is either not recognized or when using the full reference: "Microsoft.Extensions.Configuration" the GetSection Method is not recognized, i.e. Configuration class not being recognized GetSection method not being recognized Any ideas on how to use this?

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

Use appsettings to drive environment specific settings such as UseUrls

放肆的年华 提交于 2019-12-22 05:13:55
问题 When I'm developing locally using VS Code, I'm going to use port 3000 because I'm a hipster. The non-hipsters want it on port 8080 on the server. That's cool, we got this. Microsoft docs give me the following example: public static void Main(string[] args) { var config = new ConfigurationBuilder() .AddJsonFile("hosting.json", optional: true) .AddCommandLine(args) .Build(); var host = new WebHostBuilder() .UseConfiguration(config) .UseKestrel() .Configure(app => { app.Run(async (context) =>

What is IViewLocationExpander.PopulateValues() for in Asp.Net Core MVC

大憨熊 提交于 2019-12-22 04:58:11
问题 I'm using ASP.NET MVC CORE. I have implemented my own ViewLocationExpander so that I can structure my project the way I want and place my views where I like. This is accomplished by implementing a class that inherits from IViewLocationExpander and most of the work occurs in the following method: ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations) Everything is working pretty sweet but the interface defines a 2nd method that I don't know how to properly

Stackify Prefix doesn't collect any data in ASP.NET Core

十年热恋 提交于 2019-12-22 04:32:09
问题 I tried Prefix from Stackify as an alternative to Glimpse, which doesn't support native ASP.NET Core. According to this article and the docs, I installed the server application using chocolately. Then installed the NuGet-Package StackifyMiddleware and activated it in the Configure method - bevor MVC is added, like mentioned in the official docs. Finally, I activated .NET profiling using the tray icon and re-opened Visual Studio. The browser opened the data overview page of Prefix (http:/