asp.net-core-mvc

How to fix overlapping Google Chart legend

落爺英雄遲暮 提交于 2019-12-02 00:33:21
This has been something I've been working on for hours now and I can't seem to find a solution that works. I have a page (ASP.NET Core) that has bootstrap tabs on it. Each tab displays a different chart. I've read various answers and tried so many different things from this and other sites but I'm sure what I'm doing wrong. This is a proof of concept page I'm making and from what I understand I need to stall the loading of the chart until the nav-tab is selected. That is what I am unsure of how to do. My View: <html> <head> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap

CORS works for direct requests to API but not for static files (like css)

元气小坏坏 提交于 2019-12-01 23:48:57
We are developing a project which is consisted of an Android Mobile App along with a Web API . The web API is Asp.net MVC Core. I have enabled the CORS service on my Startup.cs , hence Mobile app API calls are Cross Origin accessible and I receive access-control-allow-origin →* in the response headers. A part of the result that API returns to the mobile app request is HTML (to be shown as an ad in a mobile view) containing some CSS files. When the HTML is loaded in the Mobile View, CSS files do not load because they seem not to be Cross Origin accessible. Is there something I'm missing? Have I

Azure Web App (MVC 6) continuous deployment fails

淺唱寂寞╮ 提交于 2019-12-01 23:38:33
问题 I'm trying to set up continous deployment for an Azure Web App from Bitbucket. The deployment however fails with the following error: Command: deploy.cmd Handling ASP.NET 5 Web Application deployment. Invoke-Command : Cannot validate argument on parameter 'Architecture'. The argument "undefined" does not belong to the set ",x86,x64,arm" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again. At C:\Program Files (x86)\SiteExtensions\Kudu\49

How to avoid calling ModelState.IsValid on every PostBack?

一笑奈何 提交于 2019-12-01 23:21:43
I pretty much always want to check if ModelSate.IsValid is called when I do a postback. And having to check at the start of every post back violates the DRY principle, is there a way to have it checked automatically? Example: [HttpPost("RegisterUser")] [AllowAnonymous] public async Task<IActionResult> RegisterUser([FromBody] UserRegisterViewModel vmodel) { if(!ModelState.IsValid) // This code is repeated at every postback return ModelInvalidAction(); // Is there a way to avoid having to write it down? // do other things return StatusCode(201); } The framework provides an abstract

“Cannot find compilation library location for package ”enc.dll“” error occur .net core dependency injection

房东的猫 提交于 2019-12-01 22:52:55
I am building a website using asp.net core mvc, and for the login i added dependency for enc.dll file, which just encrypt/decrypt user information. I made a Seeder class with enc.dll file, which has a key property and en/decrypt with the key. Then I added it to my service to use dependency injection feature. services.AddSingleton<ISeeder, Seeder>(); While it works well when i call enc, dec function of seeder class, it does not return any error. Below is the example code. private readonly ISeeder seed; public AccountController(ISeeder seed) { this.seed = seed; } [HttpGet] public IActionResult

Current URL in ASPCore Middleware?

不羁的心 提交于 2019-12-01 22:26:34
Is there a way I can access the current Requested URL in ASPCore 2.0 Middleware? Is there something I can Inject? Shyju HttpContext object will be passed to the Invoke method of your middleware. You can access the Request property on that. You can use the GetDisplayUrl extension method or GetEncodedUrl extension method. public Task Invoke(HttpContext context) { var url1 =context.Request.GetDisplayUrl(); var url2 = context.Request.GetEncodedUrl(); // Call the next delegate/middleware in the pipeline return this._next(context); } These 2 extension methods are defined in Microsoft.AspNetCore.Http

Azure Web App (MVC 6) continuous deployment fails

梦想的初衷 提交于 2019-12-01 22:16:21
I'm trying to set up continous deployment for an Azure Web App from Bitbucket. The deployment however fails with the following error: Command: deploy.cmd Handling ASP.NET 5 Web Application deployment. Invoke-Command : Cannot validate argument on parameter 'Architecture'. The argument "undefined" does not belong to the set ",x86,x64,arm" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again. At C:\Program Files (x86)\SiteExtensions\Kudu\49.41216.1976\bin\scripts\dnvm.ps1:1914 char:9 + Invoke-Command ([ScriptBlock]::Create("dnvm-$cmd

Reloading Options with reloadOnChange in ASP.NET Core

十年热恋 提交于 2019-12-01 21:29:56
In my ASP.NET Core application I bind the appsettings.json to a strongly typed class AppSettings . public Startup(IHostingEnvironment environment) { var builder = new ConfigurationBuilder() .SetBasePath(environment.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{environment.EnvironmentName}.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables(); Configuration = builder.Build(); } public void ConfigureServices(IServiceCollection services) { services.Configure<AppSettings>(Configuration); //... } In a singleton

Asp.Net core 2.0 MVC anchor tag helper not working

两盒软妹~` 提交于 2019-12-01 21:21:21
I am trying to create a demo page, and can't solve the next problem, and I tried everything what I found on the web. I have an anchor tag with tag helper: <a class="menu-link" asp-area="" asp-controller="Telefon" asp-action="Index">Telefonok</a> I also added a _ViewImports.cshtml and in it I added as I saw in the net @addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers" , but I still got an error: The name 'addTagHelper' does not exist in the current context What did I wrong?! There are two _ViewImports.cshtml, you probably need the one located in the Views Folder. In my project I have a another

Cookies in ASP.NET Core rc2

家住魔仙堡 提交于 2019-12-01 21:08:22
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) For getting request cookie value: HttpContext.Request.Cookies["<key>"] Setting response cookie: HttpContext.Response.Cookies.Append("<key>", <value>, <options?>)