asp.net-core-mvc

How do I debug an ASPNET Core MVC Application Deployed in Azure

[亡魂溺海] 提交于 2019-12-07 03:29:10
问题 I've created a simple ASPNET Core 1.0 MVC app, which I am trying to deploy to Azure using Visual Studio. I am able to run this app locally on my machine using IIS Express, and navigate to my default route and display the page. However, in Azure I always get a 500 error every time, and at this point I am at a loss for how to get additional information. I've enabled detailed request logging in my Azure app, but it doesn't really seem to tell me much. ModuleName="AspNetCoreModule", Notification=

ASP.NET mvc View with IEnumerable model and input tag helper

妖精的绣舞 提交于 2019-12-07 03:19:40
问题 In this official ASP.NET Core tutorial, I can use an Input Tag Helper as shown below. But due to a known model binding issue of form elements in a foreach loop, I want to use for loop instead. Question : If I were to replace @foreach (var item in Model) with @for (int i=0; i < Model.Count(); i++) in the following View . What would be my asp-for in <input asp-for="???" /> ? For some reason, intellisense is not recognizing, e.g, Model[i].BlogId or @Model[i].BlogId @model IEnumerable

Convention based binding in ASP.NET 5 / MVC 6

▼魔方 西西 提交于 2019-12-07 03:10:15
问题 It is possible to register dependencies manually: services.AddTransient<IEmailService, EmailService>(); services.AddTransient<ISmsService, SmsService>(); When there are too much dependencies, it becomes difficult to register all dependencies manually. What is the best way to implement a convention based binding in MVC 6 (beta 7)? P.S. In previous projects I used Ninject with ninject.extensions.conventions . But I can't find a Ninject adapter for MVC 6. 回答1: No, there is no support for batch

ASP.Net Core 2 ServiceProviderOptions.ValidateScopes Property

眉间皱痕 提交于 2019-12-07 02:13:45
问题 What is ServiceProviderOptions.ValidateScopes exactly? I feel I couldn't understand completely what it does under the hood. I've come across this with a tutorial, but no explanation. 回答1: I assume you are speaking about this piece of code: services.BuildServiceProvider(new ServiceProviderOptions { ValidateScopes = true }); // or services.BuildServiceProvider(true); // or false ? The ASP.NET Core Provider has a mechanic which validates if a scoped service is resolved by a singleton container.

Running MVC6 Beta8 app on IIS Express

我们两清 提交于 2019-12-07 01:59:44
问题 I just updated to MVC6 Beta8. After a few hours fixing the code to compile again, I run into an issues that the app does not run under IIS Express. I'm getting this error message: [TypeLoadException: Could not load type 'Microsoft.Dnx.Host.Clr.EntryPoint' from assembly 'Microsoft.Dnx.Host.Clr, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.] System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception

What to use instead of WebViewPage.RenderPage method in ASP.NET 5 MVC6

人盡茶涼 提交于 2019-12-07 01:55:25
问题 Given an example based on old MVC5: Views/Shared/Index.cshtml - a view for a SPA app. It contains some markup and a reference to a layout-page: @{ Layout = "~/Views/Shared/_Layout.cshtml"; } In _Layout.cshtml there're number of includes which are being used via RenderPage helper: @RenderPage("~/Views/Shared/_ImportCssInline.cshtml") @RenderPage("~/Views/Shared/_ImportCssLinks.cshtml") Now in AspNet5 @RenderPage helper isn't available. It was the method of WebViewPage / WebPageBase /

How can I set a global variable in razor page of .net core?

百般思念 提交于 2019-12-07 01:42:28
I wanna to check if the browser is IE and do something in razor page. I just made a function in razor page to do that. However,I think use the function to check if the browser is IE in every razor page is redundant.For independent user,I just need to check this only one time and set a global variable that IsIE=true/false.And other page will easily know that if it is IE. The question is how can I get/set a global variable in razor page? Thank you. ———————————————— To @Neville Nazerane ,here is the function which to check if is IE: @{ Boolean IsIE = false; string UA = Context.Request.Headers[

Cannot debug in Visual Studio after changing the port number?

£可爱£侵袭症+ 提交于 2019-12-07 01:40:20
问题 I added the line .UseUrls("http://*:5000") to enable clients from other hosts accessing the web api. public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .UseUrls("http://*:5000") // Added .Build(); host.Run(); } However, using browser to access localhost:5000/api/Test got the error of HTTP/1.1 400 Bad Request ? Should the .UseUrls() be only compiled for production?

how to plugin custom viewengine in MVC 6 beta7?

蓝咒 提交于 2019-12-07 01:37:00
问题 in beta6 we were able to plugin a custom viewengine like this: services.AddMvc() .AddViewOptions(options => { options.ViewEngines.Clear(); options.ViewEngines.Add(typeof(MyCustomViewEngine)); }); this no longer works in beta7 and options.ViewEngines seems to have changed to an IList<IViewEngine> I don't understand how to plug one in without having to new it up and provide its dependencies options.ViewEngines.Add(new it up here?); How can I plug in my own custom viewengine in beta7? 回答1: I

Populating Dropdown in ASP.net Core

こ雲淡風輕ζ 提交于 2019-12-07 00:35:54
问题 Does anyone know how to deal with Dropdowns in Asp.net core. I think I made myself very complicated to understand the new Asp.net core concept. (I am new to Asp.net Core). I have models called Driver , Vehicle . Basically one can create bunch of vehicles in the master then attach it to the Driver. So that the driver will be associated with a vehicle. My problem is that I am also using viewmodel in some area to combine two different models.(understood little from default template) My problem