asp.net-core-mvc

MVC 6 - Areas Routing is not redirecting to the configured page

风格不统一 提交于 2019-12-12 03:36:11
问题 I am working on "Microsoft.AspNetCore.Mvc": "1.1.2" My project folder structure is as below Code in startup.cs is below When I run my project I am not redirected to the index page. It shows 404 Error. Am I missing any setting? 回答1: Your url should have this pattern (due to your routes configuration): http://localhost:your_port_number/area_name When you run your application your url pattern is: http://localhost:your_port_number There is no area name in the url. You should specify the area

ASP.NET 5 Controller method can't receive JSON POST, ASP.NET 4 controller method does

雨燕双飞 提交于 2019-12-12 03:32:34
问题 I have been tearing my hair out over this one. I have two projects one running ASP.NET 4 and the other ASP.NET 5 RC1 The ASP.NET 5 project controller received POST method input parameters are all default and not the values as sent from the webpage. To narrow down the problem I simplified the controllers POST methods in both projects [HttpPost] public JsonResult DataHandler(int Draw) { //above Draw variable not set } and put a break point on the method to catch the variable Draw . The webpage

Deploying MVC 6 website to Azure results in error 502

不打扰是莪最后的温柔 提交于 2019-12-12 03:28:17
问题 I used to have no problem with deploying my asp.net 5/mvc6 website to my Azure apps/website environment, but last months I'm having weird issues. If I deploy my website to Azure, 90% of the times, the browser will be opened automatically when the deploy succeeded, and it will just load for 5 minutes and eventually will give me a 502 error or a 500 error for timeout. I can redeploy many times but it will never work. I can't pinpoint the difference between a basic empty website and my website

Dropdownlists not populating with data from 3 separate reference tables

主宰稳场 提交于 2019-12-12 03:26:31
问题 Currently I am working with ASP.Net MVC 6 using EF7. I am using the default controller generator. For some reason my drop downs are not populating with data on the create or edit page even though data is present. Just to clarify the 3 select lists are being populated by 3 different tables that are all connected to the main table I am adding to. Here's what I got. Controller code private readonly SchoolContext _context; public SchoolsController(SchoolContext context) { _context = context; }

VS2015: Remote Debug Azure Site

末鹿安然 提交于 2019-12-12 03:22:13
问题 I cannot get Visual Studio 2015 to attach remotely to my Azure site. Or, rather, it attaches okay, but no breakpoints are ever hit. I've confirmed I'm publishing a debug build. I tweaked web.config to require that. I've confirmed remote debugging support for 2015 is activated within the Azure portal. The site launches fine after the attachment...just no breakpoints. This is an MVC6 site using rc1. 回答1: For the sake of other people struggling with this, it turns out VS2015, even with all the

Find database of Web API project on Visual Studio 2015 LocalDB

十年热恋 提交于 2019-12-12 02:53:49
问题 I'm developing a Code First Web API using ASP.NET 5 and MVC 6. I can test my models and controllers locally and in Azure using a publish profile, but I want to see if the database is applying some constraints. I read that I can see the database's Tables and Columns using the SQL Server Object Explorer. When I go to View > SQL Server Object Explorer I can see the following: (localdb)\MSSQLLocalDB (localdb)\ProjectsV12 (localdb)\v11.0 I know that v11.0 was used on VS 2012 and it was changed to

add claims to windows identity

牧云@^-^@ 提交于 2019-12-12 02:37:58
问题 I am trying to assign roles as claims for Windows Authentication for Asp.net Core Webapi project. Below is my transform by adding a role claim current identity. public class ClaimsTransformer : IClaimsTransformer { public Task<ClaimsPrincipal> TransformAsync(ClaimsTransformationContext context) { //add new claim var ci = (ClaimsIdentity) context.Principal.Identity; var c = new Claim(ClaimTypes.Role, "admin"); ci.AddClaim(c); return Task.FromResult(context.Principal); } } And this middleware

Attribute routing to controller action isn't working in ASP.NET Core

二次信任 提交于 2019-12-12 02:26:46
问题 I've set breakpoints, and followed the flow. The controller is being instantiated, and the parameters are being validated (I have some Data Annotations set up), but the controller method itself isn't being invoked. I think the problem is routing, but I'm not sure where it might be broken. I haven't set up any global routing; everything is done via attributes. The Swagger docs are being generating, too, and documenting the controller endpoints. In fact, everything seems to work OK on the

Thread.CurrentThread.CurrentUICulture in asp.net Core

纵饮孤独 提交于 2019-12-12 02:25:14
问题 In my MVC application I have had the following line and it has worked fine. if (Thread.CurrentThread.CurrentUICulture.Name == localizationItem.CultureInfo.Trim()) Now as I am porting my application over to .Net Core 1.1, it appears that CurrentUICulture has went missing in action. Any ideas on what it's replacement is? Severity Code Description Project File Line Suppression State Error CS1061 'Thread' does not contain a definition for 'CurrentUICulture' and no extension method

Targeting Runtime for New MVC6 Project in VS 2015

橙三吉。 提交于 2019-12-12 02:24:50
问题 I am using ASP.NET beta 7, VS 2015 on Windows 7. When I create a new MVC6 project in VS2015 targeting .NET 4.6 framework, my project references look like this: DNX 4.5.1 DNX Core 5.0 I don't wish to create for cross platform, and would expect my references to look like this (from other tutorials): ASP.NET 5.0 ASP.NET Core 5.0 From the ASP.NET 5.0 documentation: What I'm seeing in VS 2015 (no check box option for dnx): Should I just manually hack the project.json file? "frameworks": { "dnx451"