asp.net-core-mvc

Running MVC Web app targeting .net 4.6.1 in a virtual directory under a ASP.NET core web app. Is it possible? [duplicate]

霸气de小男生 提交于 2020-01-15 10:43:12
问题 This question already has an answer here : ASP.NET 4.5 throws 502.5 as a virtual application in Azure Web App under a ASP.NET Core 2.0 application (1 answer) Closed 2 years ago . I've converted my personal website from ASP.NET to ASP.NET Core Web app (.net framework). I've uploaded this to azure app services and works fine. I would now like to run my blog (which is a ASP.NET MVC web app targeting .net 4.6.1) in a virtual application called Blog. Is this possible and if so what steps do I need

Retrieving access token in controller

僤鯓⒐⒋嵵緔 提交于 2020-01-15 08:04:06
问题 I am developing an ASP .Net Core 1.1 MVC web app which calls a web API using the "Authorization Code Grant Flow". I am using Auth0 for the authentication server. Following the Auth0 tutorials, at the point the user has successfully logged in to the web app, and now does something that makes the web app call upon the web api, it says I should get the access token as follows: public async Task<IActionResult> Index() { string accessToken = User.Claims.FirstOrDefault("access_token")?.Value; if

How to upload file with JQuery to MVC VNext webserver?

限于喜欢 提交于 2020-01-15 05:32:32
问题 I want to be able to send a file to a MVC VNext webserver. I've read this article, it works and its all good. But how do it upload a file without using <form> ? The reason for this, is because i want to upload a file without loading a new page. I've read this article, but it doesn't seem to work. The parameter IFormFile is allways null. 回答1: Try using input type="file" , FormData , $.post() $.ajaxSetup({processData:false,contentType:false}); $("input[type=file]").change(function() { var data

ASP .NET Core MVC: What happens to a request on RedirectToAction

坚强是说给别人听的谎言 提交于 2020-01-15 03:54:06
问题 I was trying to pass data around between controllers all day long, but now I'm at the point where I think I haven't quite understood the basics. Throughout the documentation of ASP .NET core, they use the word "request". I was under the assumption that this is the HttpRequest that is made by the client of the WebServer. There are also different things that are supposed to be bound to the lifetime of a request: The HttpContext and its HttpContext.Items dictionary. Services added with AddScoped

RavenDB UniqueConstraint doesn't seem to work

与世无争的帅哥 提交于 2020-01-15 03:34:06
问题 I've been trying for a day to get UniqueConstraint working, but it doesn't seem the are. I have a simple MVC6 site that creates a User on a POST. I'm expecting that on the second POST an exception should be thrown as a user will have already been created with the same properties. I'm wanting to ensure that the email address is unique. using Raven.Client; using Raven.Client.Document; using Raven.Client.UniqueConstraints; namespace MVC6Test.DomainModel { public class User { public string Id {

AddJsonOptions for MvcJsonOptions in Asp.Net Core 2.2

风流意气都作罢 提交于 2020-01-15 03:23:07
问题 I have read this question and this one about AddJsonOptions in older version (2.0 and 2.1 respectively). I'm Using Asp.net Core 2.2 but there is not such method of AddJsonOptions under services . I also checked the documentation for asp.net core 2.1 where exist the MvcJsonOptions and AddJsonOptions for Core 2.1 but when changing it to version 2.2 it states there is no such page for that version. Does anyone know where is gone this Service? 回答1: As mentioned here MvcJsonOptions is moving to

ASP.NET Core Localization - Doesn't return Value from resource file, only Name

馋奶兔 提交于 2020-01-15 01:52:09
问题 I'm trying to implement Localization, but when run only the Name returns. Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddLocalization(options => options.ResourcesPath = "Resources"); services.AddMvc() .AddViewLocalization() .AddDataAnnotationsLocalization(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { ..... List<CultureInfo> supportedCultures = new List<CultureInfo> { new CultureInfo("no"), new

How to write a custom ASP.NET 5 taghelper that contains other taghelpers

大憨熊 提交于 2020-01-14 09:46:08
问题 I've been looking at examples on taghelpers on google but couldn't find any example I'm looking for. I have the following code: <div class="form-group"> <label asp-for="PersonName" class="col-md-2 control-label"></label> <div class="col-md-10"> <input asp-for="PersonName" class="form-control" /> <span asp-validation-for="PersonName" class="text-danger"></span> </div> </div> What i'd look to do is replace it with something like <bootstraprow asp-for="PersonName"></bootstraprow> However I'm not

Ajax with ViewComponent

ⅰ亾dé卋堺 提交于 2020-01-14 08:04:21
问题 How to use AJAX for ViewComponent in Asp.Net Core? That is calling the method @Component.Invoke ("ComponentName", SomeData); ViewComponent will involve various views depending on SomeData without rebooting the main view. Update My solution is: $(function () { $(Container).load('ControllerName/ControllerAction', { ArgumentName: ArgumentValue }); }); Controller : public IActionResult ControllerAction(string value) { return ViewComponent("ViewComponent", value); } Is there a way to directly use

Could not load file or assembly 'System.Runtime.Loader' for adding application parts into MVC

只愿长相守 提交于 2020-01-14 08:00:54
问题 I'm trying to load application parts into an ASP.NET Core 2.0 MVC appication by using the System.Runtime.Loader package but it won't let me. The error message says: FileNotFoundException: Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. In the Startup.cs I use it like this (it should just be proof of concept that this works so I can move it into a