asp.net-core-mvc

Launch external process (.exe) from asp.net core app

荒凉一梦 提交于 2019-12-22 22:46:36
问题 I have the following [HttpPost] public IActionResult LaunchExternalProcess() { Process.Start("C:\\Windows\\System32\\calc.exe"); return Ok(); } And this works perfectly fine on my local machine, but when deployed onto IIS 10 (windows 2016) I get no errors but it does not launch the calc on the server. I simply want to call an external .exe from a button on my page. Here is the javascript that I am using which also works on my local but no errors on server and it displays the success message $

Path based authentication in ASP.NET Core MVC 2.0

醉酒当歌 提交于 2019-12-22 12:37:17
问题 In ASP.NET Core MVC 1.1 we had path based authentication like this: public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { // /api/* path app.UseWhen(ctx => IsApiRequest(ctx), subBranch => { subBranch.UseApiAuth(GetApiAuthOptions()); }); // else app.UseWhen(ctx => !IsApiRequest(ctx), subBranch => { subBranch.UseOpenIdConnectAuthentication(GetOpenIdOptions()); }); } Now we want to migrate it to ASP.NET Core MVC 2.0. In new version authentication

Access appsettings.json file setting from the class library project

柔情痞子 提交于 2019-12-22 11:29:00
问题 I know how to set appsettings.json file on web project.But can you tell me how to access that from the class library project ? I can configure it as shown below on the web project.Then how can I access that values from the class library project ? Is that possible ? public class MyConfig { public string ApplicationName { get; set; } public int Version { get; set; } } public class Startup { public IConfigurationRoot Configuration { get; set; } public Startup(IHostingEnvironment env) { var

using aspnet identity with custom tables

核能气质少年 提交于 2019-12-22 10:52:54
问题 I am working on asp.net MVC core application. I have custom database with users and roles tables. I want to use asp.net identity with custom tables so that I don't have to use aspnetusers, aspnet roles tables. How to do it with asp.net identity and asp.net core 回答1: Good luck with that! :) I have just gone through that process last few days. I've got it to work but its really painful at some stages. In short: You need to create your own user model that implements IUser interface. You need to

The property is of an interface type ('IFormFile') MVC Core

半腔热情 提交于 2019-12-22 10:45:32
问题 I'm trying to make a form that i could save a file(image) , but it shows me an error: InvalidOperationException: The property 'Product.Image' is of an interface type ('IFormFile'). If it is a navigation property manually configure the relationship for this property by casting it to a mapped entity type, otherwise ignore the property from the model. Apply I dont know how to fix it , here's the code: Product.cs public class Product { public Product() { OrderDetails = new HashSet<OrderDetails>()

TagHelper cached output by calling GetChildContentAsync() and Content.GetContent()

前提是你 提交于 2019-12-22 10:35:07
问题 According to this article if we use several tag helpers(targeted to the same tag) and in each of them we will use await output.GetChildContentAsync() to recieve html content we will come to the problem with cached output: The problem is that the tag helper output is cached, and when the WWW tag helper is run, it overwrites the cached output from the HTTP tag helper. The problem is fixed by using statement like: var childContent = output.Content.IsModified ? output.Content.GetContent() :

Call Signalr method from Controller .Net Core 2.1

让人想犯罪 __ 提交于 2019-12-22 09:28:36
问题 I am trying to call a method in the signalr Hub class from an (ASP.NET Core) MVC Controller, but I cannot find an example online that shows how to. Note: There are lots of examples using older versions of signalr with the .Net Framework, but none that I can see that show how to do this in .Net Core. I need to pass an id from the an MVC Action Result directly through to my Hub, without passing the id to the page, and then having to get a client connection back through to the hub. public class

ASP.NET Core Identity 3 Cookie timeout

本小妞迷上赌 提交于 2019-12-22 07:57:51
问题 I have a weird issue happening with RC2. I have setup Identity 3 ExpireTimeSpan to 12 hours using the following configuration option options.Cookies.ApplicationCookie.ExpireTimeSpan = new TimeSpan(12,0,0); After logging in to the website and leaving it untouched for ~35-40mins, I get a 401 error (for my ajax post calls) and refreshing the website, I get back to the login page. Why do I have to reauthenticate when I have setup the ExpireTimeSpan to 12hours? Is there another setting or

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

APK packages is not served in ASP.NET Core MVC

回眸只為那壹抹淺笑 提交于 2019-12-22 07:01:51
问题 I want to serve .apk files in my ASP.NET Core MVC project, and I can't since it returns 404. I created a simple ASP.NET Core MVC project using default template in VS 2017, and added the .apk file to wwwroot folder, and then I tried to reach it using /application.apk path, and it didn't work, while /favicon.ico works, and other static contents in that directory work, because in default template app.UseStaticFiles() is called. I then tried to change configurations, brought static contents out