asp.net-core-mvc

How do I get the details of an Error 500 for an Azure Web App?

感情迁移 提交于 2019-12-09 16:12:20
问题 I have an MVC 6 site that has been deployed as an Azure Web App. I have enabled all tracing / diagnostic options in Visual Studio using Server Explorer. I am trying to do remote debugging, but I am only seeing an Error 500 on my browser, and not finding any information (or triggering an error breakpoint) on where exactly the error occurred. I can't find any error trace on the file logs that I get from Azure. How should I troubleshoot Error 500's in an Azure Web App? Adding "CustomErrors": {

How to invoke a View Component from controller

戏子无情 提交于 2019-12-09 15:10:16
问题 Is it possible to invoke a View Component from controller and render it to a string? I am really looking for some code example for this. Any help will be much appreciated. 回答1: You can do that but you have to apply following thing as It is render by DefaultViewComponentHelper. You have to create instance of this and to create that you need IViewComponentSelector and IViewComponentInvokerFactory. To do this I have done following thing. public class HomeController : Controller { Microsoft

How important is the global.json and src folder?

血红的双手。 提交于 2019-12-09 14:36:46
问题 In VS 2015, when you create a new MVC 6.0 application using this approach: File-->New-->Project-->ASP.NET Web Application-->ASP.NET 5 Preview Templates You end up have the following file structure on disk: artifacts src MyProject.sln global.json Instead if I decide to create a blank solution first like so: File-->New-->Project-->Other Project Types-->Visual Studio Solutions-->Blank Solution And start adding a new ASP.NET Web Application project to this solution; you end up having a file

Visual Studio .net core tag helpers not working

杀马特。学长 韩版系。学妹 提交于 2019-12-09 14:31:01
问题 Well, lets get down to it. I'm using Visual Studio 2015 and ASP.NET core tag helpers have completely stopped working, no idea why as I've not changed anything. I was in work one day, they worked fine, then I came in the next day and now no ASP.NET core web project at all shows any tag helpers!?! I've tried creating a fresh new ASP.NET core mvc project and they don't work there either!!! I'm completely stuck, is there some setting somewhere that completely turns them off in Visual Studio? Note

Using Startup class in ASP.NET5 Console Application

孤者浪人 提交于 2019-12-09 14:14:38
问题 Is it possible for an ASP.NET 5-beta4 console application (built from the ASP.NET Console project template in VS2015) to use the Startup class to handle registering services and setting up configuration details? I've tried to create a typical Startup class, but it never seems to be called when running the console application via dnx . run or inside Visual Studio 2015. Startup.cs is pretty much: public class Startup { public Startup(IHostingEnvironment env) { Configuration configuration = new

Add namespace to all views in ASP.NET MVC 6

时间秒杀一切 提交于 2019-12-09 14:07:10
问题 I’m using MVC 6 and would like to be able to access a particular namespace globally from all of my Razor views. In MVC 5 this was fairly simple; I’d just add the following code to my ~/views/web.config file: <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace=

How to deploy ASP.NET Core UserSecrets to production

一曲冷凌霜 提交于 2019-12-09 14:04:14
问题 I followed the Safe storage of app secrets during development guide over on the asp.net docs during development but it does not describe how to use it when publishing to another machine for QA, Production, etc. What I figured it would do was insert them into the appsettings.json during publish but it does not. I ended up having to place my SendGrid keys and other sensitive information directly into the appsettings.json which really defeats the purpose of the app secrets. Is using app secrets

Get AD info for user in Windows Authentication for ASP .NET Core

冷暖自知 提交于 2019-12-09 13:31:44
问题 Working on an intranet app in .NET Core and I'd like to retrieve information connected to the AD users. Currently, all authentication is handled by Windows and works great. Is there a way I can pull data from AD? I'd like to get information like first and last name, e-mail, ID, etc. 回答1: Using.net core 2.1.1 Install "System.DirectoryServices" from NuGet using System.DirectoryServices; var name = User.Identity.Name.Split('\\')[1]; *@I was getting name as domain\\name @* DirectorySearcher ds =

Getting reference of Startup.cs object

北慕城南 提交于 2019-12-09 12:30:17
问题 Here's the skeleton of a standard ASP.NET Core application: var config = new ConfigurationBuilder() .AddCommandLine(args) .AddEnvironmentVariables(prefix: "ASPNETCORE_") .Build(); var host = new WebHostBuilder() .UseConfiguration(config) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); In this piece the ASP.NET Core apparatus instantiates an instance of Startup.cs class .UseStartup<Startup>() My query is how can I

ASP.NET 5 RC1: System.IO.InvalidDataException: Unexpected end of request content

大城市里の小女人 提交于 2019-12-09 12:04:46
问题 I am running an ASP.NET 5 project in an Azure Web App. When calling on an API endpoint with a file (form-data) of about 1.5mb or larger, the following exception is thrown. Here is where the exception is thrown from. Does anyone know how this can be fixed? Is there a possible workaround? System.IO.InvalidDataException: Unexpected end of request content at Microsoft.AspNet.Server.Kestrel.Http.MessageBody.ForContentLength.d__3.MoveNext() --- End of stack trace from previous location where